krysalis-update/src/java/org/krysalis/depot/update/artifact ArtifactAttributeMap.java,NONE,1.1 ArtifactConstants.java,NONE,1.1 ArtifactLocator.java,NONE,1.1 ArtifactType.java,NONE,1.1 ArtifactGroup.java,NONE,1.1 ArtifactAttribute.java,NONE,1.1

Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:36 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-update/src/java/org/krysalis/depot/update/artifact
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/java/org/krysalis/depot/update/artifact

Added Files:
	ArtifactAttributeMap.java ArtifactConstants.java 
	ArtifactLocator.java ArtifactType.java ArtifactGroup.java 
	ArtifactAttribute.java 
Log Message:
Copied from the apache incubator.

--- NEW FILE: ArtifactGroup.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.krysalis.depot.update.artifact;
/**
 * 
 * 
 * @author <a href="http://incubator.apache.org/depot">The Apache Incubator Depot Project</a>
 */
public class ArtifactGroup {
	public String m_name = null;
	
	/**
	 * Constructor
	 * Builds an artifactGroup with the specified name
	 * 
	 * @param name name of the ArtifactGroup
	 */
	public ArtifactGroup(String name) {
		if(name == null)throw new NullPointerException("name of the group must be set");
		m_name = name;
	}	
	
	/*
	* (non-Javadoc)
	* 
	* @see java.lang.Object#equals(java.lang.Object)
	*/
	public boolean equals(Object otherGroup) {
		return m_name.equals(((ArtifactGroup) otherGroup).getName());
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return m_name.hashCode();
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return m_name;
	}
	
	/**
	 * Gets the groupidentifier of this group
	 * 
	 * @return groupidentifier
	 */
	public String getName() {
		return m_name;
	}
	
	/**
	 * returns a group for test purposes
	 * 
	 * @return a Test artifactGroup
	 */
	public static ArtifactGroup getTestGroup() {
		return getTestGroup("test");
	}
	
	/**
	 * returns a group for test purposes with the given identifier/name
	 * 
	 * @param name The identifier of the testgroup
	 * @return a Test artifactGroup
	 */	
	public static ArtifactGroup getTestGroup(String name) {
		return new ArtifactGroup(name);
	}
}
--- NEW FILE: ArtifactLocator.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.krysalis.depot.update.artifact;

import java.io.PrintWriter;

import org.krysalis.depot.update.util.net.VirtualResourceLocator;
import org.krysalis.version.util.DebugUtils;

/**
 * @author arb_jack
 * 
 * 
 */
public class ArtifactLocator  {

	//
	//	Where is this thing?
	//	
	private String m_filename = null;
	private String m_extension = null;
	
	
	// :TODO: Do we want to add reference to repository?
	// :TODO: Are above to obsolete w/ below?
	
	private VirtualResourceLocator m_location = null;

	//
	// Construct an ArtifactLocator
	//
	public ArtifactLocator(
		String filename,
		String extension,
		VirtualResourceLocator location) {

		m_filename = filename;
		m_extension = extension;
		m_location = location;
	}

	/**
	 * Constructor
	 * Creates a new ArtifactLocator from another ArtifactLocator
	 * 
	 * :TODO: should be deleted, see the clone method of the class
	 * 
	 * @param other
	 * @deprecated see clone()
	 */
	public ArtifactLocator(ArtifactLocator other) {

		m_filename = other.m_filename;
		m_extension = other.m_extension;
		m_location = other.m_location;
	}

//:TODO: fix these
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object other) {
		boolean equal = true;

		if (other instanceof ArtifactLocator) {
			ArtifactLocator otherResourceLocator = (ArtifactLocator) other;

			equal = otherResourceLocator.m_location.equals(m_location);

			if (null == m_filename)
				equal &= (null == otherResourceLocator.m_filename);
			else
				equal &= otherResourceLocator.m_filename.equals(m_filename);
			
			if (null == m_filename)
				equal &= (null == otherResourceLocator.m_filename);
			else
				equal &= otherResourceLocator.m_filename.equals(m_filename);
		}
		else
			throw new IllegalArgumentException(
				"Not a ResourceLocator: " + other.getClass().getName());

		return equal;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		int hash = 0;

		hash += m_location.hashCode();
		
		return hash;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		StringBuffer buffer = new StringBuffer();

		if (null != m_filename) {
			buffer.append(m_filename);
		}
		
		if (null != m_location) {
			buffer.append(':');
			buffer.append(m_location.toString());
		}

		return buffer.toString();
	}

	public void dump(PrintWriter out, int depth, boolean verbose) {
		String indent = DebugUtils.getIndent(depth);

		out.print(indent);
		out.println("ResourceLocator Filename: " + m_filename);
		
		out.print(indent);
		out.println("ResourceLocator Extn: " + m_extension);

		out.print(indent);
		out.println("ResourceLocator Location: " + m_location);

	}

	/**
	 * Clones the current Object into another Object
	 */
	public Object clone() {
		ArtifactLocator aLocator = new ArtifactLocator(this.m_filename, 
						this.m_extension, this.m_location);
		return aLocator;
	}

	/**
	 * @return Returns the filename.
	 */
	public String getFilename() {
		return m_filename;
	}
	/**
	 * @return Returns the extension.
	 */
	public String getExtension() {
		return m_extension;
	}
	/**
	 * @return Returns the location.
	 */
	public VirtualResourceLocator getLocation() {
		return m_location;
	}
	/**
	 * @param extension The extension to set.
	 */
	public void setExtension(String extension) {
		m_extension = extension;
	}
	/**
	 * @param filename The filename to set.
	 */
	public void setFilename(String filename) {
		m_filename = filename;
	}
	/**
	 * @param location The location to set.
	 */
	public void setLocation(VirtualResourceLocator location) {
		m_location = location;
	}
}

--- NEW FILE: ArtifactType.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.krysalis.depot.update.artifact;

import org.krysalis.depot.update.util.identity.GenericNamespace;


/**
 * @author arb_jack
 */
public class ArtifactType extends GenericNamespace {

	public final static ArtifactType UNKNOWN =
		new ArtifactType("http://apache.org/resource/unknown", "unknown");

	public final static ArtifactType JAVA_BINARY =
		new ArtifactType("http://apache.org/resource/java", "java");

	public final static ArtifactType SOURCE_CODE =
		new ArtifactType("http://apache.org/resource/src", "src");

	public final static ArtifactType DOCUMENTATION =
		new ArtifactType("http://apache.org/resource/docs", "docs");

	public ArtifactType(String uri, String prefix) {
		super(uri, prefix);
	}

	public static ArtifactType getFromString(String typeStr) {
		ArtifactType type = ArtifactType.UNKNOWN;

		if ((null == typeStr) || ("" == typeStr) || ("java" == typeStr)) {
			type = ArtifactType.JAVA_BINARY;
		}
		//:TODO: Hack...
		else if ("src".equals(typeStr)) {
			type = ArtifactType.SOURCE_CODE;
		}
		else if ("docs".equals(typeStr)) {
			type = ArtifactType.DOCUMENTATION;
		}

		// :TODO: 

		return type;
	}

	// :TODO: Bit of a hack to allow RT -> String -> RT
	public String toString() {
		return getPrefix();
	}
}

--- NEW FILE: ArtifactAttribute.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.krysalis.depot.update.artifact;

import org.krysalis.depot.update.util.flag.Flag;
import org.krysalis.depot.update.util.xml.IXMLAttribute;


/**
 * @author arb_jack
 */
public class ArtifactAttribute extends Flag implements IXMLAttribute{
	
	public static final String RESOURCE_ATTRIBUTE_CLASSNAME = ArtifactAttribute.class.getName();
	
	/**
	 * Where the MD5 checksum is ...
	 */
	public static final ArtifactAttribute MD5_LOCATION =
		new ArtifactAttribute(ArtifactConstants.MD5_LOCATION);

	/**
	 * Where the ASC checksum is ...
	 */
	public static final ArtifactAttribute ASC_LOCATION =
		new ArtifactAttribute(ArtifactConstants.ASC_LOCATION);

	private ArtifactAttribute(final String name) {
		super(name);
	}
}

--- NEW FILE: ArtifactConstants.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.krysalis.depot.update.artifact;

/**
 * @author anou_mana
 */
public class ArtifactConstants
{
	// Attribute
	public final static String MD5_LOCATION = "MD5_LOCATION";
	public final static String ASC_LOCATION = "ASC_LOCATION";
}

--- NEW FILE: ArtifactAttributeMap.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.krysalis.depot.update.artifact;

import java.util.List;

import org.krysalis.depot.update.util.flag.FlagMap;

/**
 * @author arb_jack
 */
public class ArtifactAttributeMap extends FlagMap {

	/**
	 * 
	 */
	public ArtifactAttributeMap() {
		super();
	}

	/**
	 * @param arg0
	 */
	public ArtifactAttributeMap(int initialSize) {
		super(initialSize);
	}
	
	/**
	* Determines if this set has a particular attribute.
	*/
	public boolean hasAttribute(ArtifactAttribute attribute) {
		return hasFlag(attribute);
	}

	/**
	* Determines if this set has a particular set of attributes.
	*/
	public boolean hasAttributes(List attributes) {
		return hasFlags(attributes);
	}
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/