ruper2/src/java/core/org/krysalis/ruper2/resource ResourceAttribute.java,NONE,1.1 ResourceConstants.java,NONE,1.1 ResourceLocator.java,NONE,1.1 ResourceAttributeMap.java,NONE,1.1 Resource.java,1.7,1.8

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/resource
In directory sc8-pr-cvs1:/tmp/cvs-serv23201/src/java/core/org/krysalis/ruper2/resource

Modified Files:
	Resource.java 
Added Files:
	ResourceAttribute.java ResourceConstants.java 
	ResourceLocator.java ResourceAttributeMap.java 
Log Message:
1) Moved IMonitor -> IFileMonitor (to allow others)
2) GroupBy now works (iterated unsorted list be accindent)
3) Started on 'clean' (remove old versions from a repo)

--- NEW FILE: ResourceAttribute.java ---
/*
 * Created on Aug 26, 2003
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.krysalis.ruper2.resource;

import org.krysalis.ruper2.util.flag.Flag;
import org.krysalis.ruper2.util.xml.IXMLAttribute;

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

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

--- NEW FILE: ResourceConstants.java ---
/*
 * Created on Aug 29, 2003
 *
 */
package org.krysalis.ruper2.resource;

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

--- NEW FILE: ResourceLocator.java ---
/*
 * Created on Aug 27, 2003
 */
package org.krysalis.ruper2.resource;

import java.io.PrintWriter;

import org.krysalis.ruper2.util.net.VirtualResourceLocator;
import org.krysalis.version.util.debug.DebugUtils;

/**
 * @author arb_jack
 * 
 * 
 * 	:TODO: This is incomplete, and not wired to anything yet. 
 * I am start to wonder if we need 'the repositoriy it is in' referenced
 * for any resoruce
 * 
 * 
 * 
 */
public class ResourceLocator  {

	//
	//	Where is this thing?
	//	
	private String m_filename = null;
	private VirtualResourceLocator m_location = null;

	//
	// Construct a ResourceLocator
	//
	public ResourceLocator(
		String filename,
		VirtualResourceLocator location) {

		m_filename = filename;
		m_location = location;

	}


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

		if (other instanceof ResourceLocator) {
			ResourceLocator otherResourceLocator = (ResourceLocator) 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);
		}
		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 Location: " + m_location);

	}


}

--- NEW FILE: ResourceAttributeMap.java ---
/*
 * Created on Aug 26, 2003
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.krysalis.ruper2.resource;

import java.util.List;

import org.krysalis.ruper2.util.flag.FlagMap;

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

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

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

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

Index: Resource.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/resource/Resource.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Resource.java	10 Oct 2003 21:26:25 -0000	1.7
--- Resource.java	12 Oct 2003 18:12:06 -0000	1.8
***************
*** 8,11 ****
--- 8,12 ----
  import java.util.List;
  
+ import org.krysalis.ruper2.util.flag.Flag;
  import org.krysalis.ruper2.util.identity.GenericIdentifier;
  import org.krysalis.ruper2.util.net.VirtualResourceLocator;
***************
*** 48,51 ****
--- 49,55 ----
  	private String m_extension = null;
  
+ 	// Annotated attributes
+ 	private ResourceAttributeMap m_attributes = null;
+ 
  	//
  	// Construct a Resource
***************
*** 199,204 ****
  			else
  				equal &= otherResource.m_version.equals(m_version);
- 
- 			//:TODO: Same for version and ... ???
  		}
  		else
--- 203,206 ----
***************
*** 249,278 ****
  	}
  
- 	public void dump(PrintWriter out, int depth, boolean verbose) {
- 		String indent = DebugUtils.getIndent(depth);
- 
- 		out.print(indent);
- 		out.println("Resource Identifier: " + m_identifier);
- 
- 		out.print(indent);
- 		out.println("Resource Type: " + m_type);
- 
- 		out.print(indent);
- 		out.println("Resource Group: " + m_group);
- 
- 		out.print(indent);
- 		out.println("Resource Filename: " + m_filename);
- 
- 		out.print(indent);
- 		out.println("Resource Extension: " + m_extension);
- 
- 		out.print(indent);
- 		out.println("Resource Location: " + m_location);
- 
- 		if (null != m_version) {
- 			out.print(indent);
- 			out.println("Resource Version: " + m_version);
- 		}
- 	}
  	/**
  	 * @return
--- 251,254 ----
***************
*** 330,333 ****
--- 306,364 ----
  	}
  
+ 	// Attribute Interface
+ 
+ 	public void setAttribute(Flag attributeName, Object attributeValue) {
+ 		if (null == m_attributes)
+ 			m_attributes.put(attributeName, attributeValue);
+ 	}
+ 
+ 	public boolean hasAttribute(Flag attributeName) {
+ 		return m_attributes.containsKey(attributeName);
+ 	}
+ 
+ 	public Object getAttribute(Flag attributeName) {
+ 		Object value = null;
+ 
+ 		if (null == m_attributes)
+ 			value = m_attributes.get(attributeName);
+ 		return value;
+ 	}
+ 
+ 	public void dump(PrintWriter out, int depth, boolean verbose) {
+ 		String indent = DebugUtils.getIndent(depth);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Identifier: " + m_identifier);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Type: " + m_type);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Group: " + m_group);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Filename: " + m_filename);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Extension: " + m_extension);
+ 
+ 		out.print(indent);
+ 		out.println("Resource Location: " + m_location);
+ 
+ 		if (null != m_version) {
+ 			out.print(indent);
+ 			if (verbose)
+ 				DebugUtils.dump(out, depth + 1, verbose, m_version);
+ 			else
+ 				out.println("Resource Version: " + m_version);
+ 		}
+ 
+ 		if (verbose && (null != m_attributes))
+ 			DebugUtils.dump(out, depth, verbose, m_attributes);
+ 	}
+ 
+ 	//
+ 	//	-----------------------------------------------------------------
+ 	//
  	public static List getTestResourceList(String group, int count) {
  		List resourceList = new ArrayList();




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.