svn commit: rev 45971 - in avalon/trunk/tools/magic: . src/main/org/apache/avalon/tools/model src/main/org/apache/avalon/tools/tasks
[email protected] 13 Sep 2004 12:11:19 -0000
| Newsgroups | gmane.comp.jakarta.avalon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: niclas
Date: Mon Sep 13 05:11:19 2004
New Revision: 45971
Modified:
avalon/trunk/tools/magic/setup.xml
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Policy.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ResourceRef.java
avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java
Log:
Formatting plus changes made to support the Magic-Eclipse-plugin.
Modified: avalon/trunk/tools/magic/setup.xml
==============================================================================
--- avalon/trunk/tools/magic/setup.xml (original)
+++ avalon/trunk/tools/magic/setup.xml Mon Sep 13 05:11:19 2004
@@ -109,8 +109,8 @@
<setproxy
proxyhost="${magic.proxy.host}"
proxyport="${magic.proxy.port}"
- proxyuser="${magic.proxy.user}"
- proxypassword="${magic.proxy.password}"/>
+ proxyuser="${magic.proxy.user}"
+ proxypassword="${magic.proxy.password}"/>
</target>
<available property="magic.junit.available"
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Context.java Mon Sep 13 05:11:19 2004
@@ -619,7 +619,8 @@
private static File setupEtc( final File basedir, final String path )
{
- if( null == path ) return new File( basedir, ETC_VALUE );
+ if( null == path )
+ return new File( basedir, ETC_VALUE );
return new File( basedir, path );
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java Mon Sep 13 05:11:19 2004
@@ -290,26 +290,48 @@
*/
public boolean equals( final Object other )
{
- if( other instanceof Info )
+ if( ! ( other instanceof Info ) )
+ return false;
+
+ final Info info = (Info) other;
+ if( isaSnapshot() != info.isaSnapshot() )
+ return false;
+ if( ! getName().equals( info.getName() ) )
+ return false;
+ if( ! getGroup().equals( info.getGroup() ) )
+ return false;
+ if( ! getType().equals( info.getType() ) )
+ return false;
+
+ if( null == getVersion() )
{
- final Info info = (Info) other;
- if( isaSnapshot() != info.isaSnapshot() ) return false;
- if( !getName().equals( info.getName() ) ) return false;
- if( !getGroup().equals( info.getGroup() ) ) return false;
- if( !getType().equals( info.getType() ) ) return false;
- if( null == getVersion() )
- {
- return ( null == info.getVersion() );
- }
- else
- {
- return getVersion().equals( info.getVersion() );
- }
+ return ( null == info.getVersion() );
}
else
{
- return false;
+ return getVersion().equals( info.getVersion() );
}
+ }
+
+ public int hashCode()
+ {
+
+ int hash;
+ if( m_version == null )
+ hash = 72367861;
+ else
+ hash = getVersion().hashCode();
+
+ if( isaSnapshot() )
+ hash >>>= 7;
+ else
+ hash >>>= 13;
+
+ hash = hash ^ m_name.hashCode();
+ hash = hash ^ m_group.hashCode();
+ hash = hash ^ m_type.hashCode();
+
+ return hash;
}
//-------------------------------------------------------------------
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Plugin.java Mon Sep 13 05:11:19 2004
@@ -59,6 +59,12 @@
return false;
}
+ public int hashCode()
+ {
+ return super.hashCode(); // NH: Is this really correct?
+ }
+
+
public static class AbstractDef
{
private String m_classname;
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Policy.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Policy.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Policy.java Mon Sep 13 05:11:19 2004
@@ -87,14 +87,25 @@
public boolean equals( final Object other )
{
- if( other instanceof Policy )
- {
- final Policy policy = (Policy) other;
- if( m_build != policy.m_build ) return false;
- if( m_test != policy.m_test ) return false;
- if( m_runtime != policy.m_runtime ) return false;
- return true;
- }
- return false;
+ if( ! ( other instanceof Policy ) )
+ return false;
+ final Policy policy = (Policy) other;
+ if( m_build != policy.m_build )
+ return false;
+ if( m_test != policy.m_test )
+ return false;
+ if( m_runtime != policy.m_runtime )
+ return false;
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = 26143876;
+ hash = m_build ? hash >>> 7 : hash >>> 3;
+ hash = m_test ? hash >>> 7 : hash >>> 3;
+ hash = m_runtime ? hash >>> 7 : hash >>> 3;
+
+ return hash;
}
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java Mon Sep 13 05:11:19 2004
@@ -161,7 +161,7 @@
for( int i=0; i<refs.length; i++ )
{
final ResourceRef ref = refs[i];
- if( !visited.contains( ref ) )
+ if( ! visited.contains( ref ) )
{
final Resource resource = getResource( project, ref );
final File file = resource.getArtifact( project, resolve );
@@ -310,20 +310,30 @@
public boolean equals( final Object other )
{
- if( other instanceof Resource )
- {
- final Resource def = (Resource) other;
- if( !getInfo().equals( def.getInfo() ) ) return false;
-
- final ResourceRef[] refs = getResourceRefs();
- final ResourceRef[] references = def.getResourceRefs();
- for( int i=0; i<refs.length; i++ )
- {
- if( !refs[i].equals( references[i] ) ) return false;
- }
+ if( ! ( other instanceof Resource ) )
+ return false;
+
+ final Resource def = (Resource) other;
+ if( ! getInfo().equals( def.getInfo() ) )
+ return false;
- return true;
+ final ResourceRef[] refs = getResourceRefs();
+ final ResourceRef[] references = def.getResourceRefs();
+ for( int i=0; i<refs.length; i++ )
+ {
+ if( !refs[i].equals( references[i] ) )
+ return false;
}
- return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = getInfo().hashCode();
+ final ResourceRef[] refs = getResourceRefs();
+ for( int i = 0 ; i < refs.length ; i++ )
+ hash = hash ^ refs[i].hashCode();
+ return hash;
}
}
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ResourceRef.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ResourceRef.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/ResourceRef.java Mon Sep 13 05:11:19 2004
@@ -111,16 +111,32 @@
public boolean equals( final Object other )
{
- if( other instanceof ResourceRef )
- {
- final ResourceRef ref = (ResourceRef) other;
- if( !getKey().equals( ref.getKey() ) ) return false;
- if( !getPolicy().equals( ref.getPolicy() ) ) return false;
- return true;
- }
- return false;
+ if( ! ( other instanceof ResourceRef ) )
+ return false;
+
+ final ResourceRef ref = (ResourceRef) other;
+
+ if( ! getKey().equals( ref.getKey() ) )
+ return false;
+
+ if( ! getPolicy().equals( ref.getPolicy() ) )
+ return false;
+
+ if( getTag() != ref.getTag() )
+ return false;
+
+ return true;
}
+ public int hashCode()
+ {
+ int hash = 926234653;
+ hash = hash ^ m_policy.hashCode();
+ hash >>>= 7;
+ hash = hash ^ ( 1876872534 >> m_tag );
+ return hash;
+ }
+
public String toString()
{
return "[resource key=\"" + getKey() + "\"]";
Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java (original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ReplicateTask.java Mon Sep 13 05:11:19 2004
@@ -40,7 +40,7 @@
public class ReplicateTask extends Task
{
private File m_todir;
- private String m_id;
+ private Path m_path;
private Context m_context;
private Home m_home;
@@ -70,9 +70,34 @@
/**
* The id of a repository based path.
*/
+ public void setRefid( Path path )
+ {
+ m_path = path;
+ }
+
+ /**
+ * The id of a repository based path.
+ */
public void setRefid( String id )
+ throws BuildException
{
- m_id = id;
+ Object ref = getProject().getReference( id );
+ if( null == ref )
+ {
+ final String error =
+ "Replication path id [" + id + "] is unknown.";
+ throw new BuildException( error );
+ }
+
+ if( !( ref instanceof Path ) )
+ {
+ final String error =
+ "Replication path id [" + id + "] does not reference a path "
+ + "(class " + ref.getClass().getName() + " is not a Path instance).";
+ throw new BuildException( error );
+ }
+
+ m_path = (Path) ref;
}
/**
@@ -85,7 +110,7 @@
public void execute()
{
- if( null == m_id )
+ if( null == m_path )
{
final String error =
"Required path id attribute is not declared on replicate task.";
@@ -98,25 +123,8 @@
throw new BuildException( error );
}
- Object ref = getProject().getReference( m_id );
- if( null == ref )
- {
- final String error =
- "Replication path id [" + m_id + "] is unknown.";
- throw new BuildException( error );
- }
-
- if( !( ref instanceof Path ) )
- {
- final String error =
- "Replication path id [" + m_id + "] does not reference a path "
- + "(class " + ref.getClass().getName() + " is not a Path instance).";
- throw new BuildException( error );
- }
-
- Path path = (Path) ref;
File cache = getHome().getRepository().getCacheDirectory();
- FileSet fileset = createFileSet( cache, path );
+ FileSet fileset = createFileSet( cache, m_path );
copy( m_todir, fileset );
}