Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/reference
In directory sc8-pr-cvs1:/tmp/cvs-serv30481/src/java/core/org/krysalis/ruper2/util/reference
Added Files:
ReferenceTable.java Referenceable.java ReferenceProxy.java
NoSuchReferenceException.java
Log Message:
Avoid clash with existing Ruper...
--- NEW FILE: ReferenceTable.java ---
/*
* Created on Aug 29, 2003
*/
package org.krysalis.ruper2.util.reference;
import java.io.PrintWriter;
import java.util.HashMap;
import org.krysalis.ruper2.util.identity.GenericIdentifier;
import org.krysalis.ruper2.util.identity.GenericNamespace;
import org.krysalis.version.util.debug.DebugUtils;
import org.krysalis.version.util.debug.Dumpable;
/**
* @author ajack
*/
public class ReferenceTable implements Dumpable {
private GenericNamespace m_namespace = null;
private HashMap m_table = new HashMap();
public ReferenceTable(GenericNamespace ns) {
m_namespace = ns;
}
public boolean hasReference(GenericIdentifier id) {
return m_table.containsKey(id);
}
public Object getReference(GenericIdentifier id) {
Object object = m_table.get(id);
if (object instanceof ReferenceProxy)
object = ((ReferenceProxy) object).getObject();
return object;
}
public void createReference(Referenceable reference) {
//:TODO: Confirm right naemspace
m_table.put(reference.getIdentifier(), reference);
}
public void createReference(String id, Object object) {
createReference(
new ReferenceProxy(new GenericIdentifier(m_namespace, id), object));
}
public void dump(PrintWriter out, int depth, boolean verbose) {
String indent = DebugUtils.getIndent(depth);
out.print(indent);
out.println(m_namespace);
DebugUtils.dump(out, depth + 1, "Table: ", verbose, m_table);
}
}
--- NEW FILE: Referenceable.java ---
/*
* Created on Aug 29, 2003
*/
package org.krysalis.ruper2.util.reference;
import org.krysalis.ruper2.util.identity.Identifiable;
/**
* @author arb_jack
*/
public interface Referenceable extends Identifiable {
}
--- NEW FILE: ReferenceProxy.java ---
/*
* Created on Aug 29, 2003
*/
package org.krysalis.ruper2.util.reference;
import org.krysalis.ruper2.util.identity.GenericIdentifier;
/**
* @author arb_jack
*/
public class ReferenceProxy implements Referenceable {
private GenericIdentifier m_identifier = null;
private Object m_object = null;
public ReferenceProxy(GenericIdentifier id, Object object) {
m_identifier = id;
m_object = object;
}
/* (non-Javadoc)
* @see org.krysalis.ruper2.util.reference.Referenceable#getRefId()
*/
public GenericIdentifier getIdentifier() {
return m_identifier;
}
/**
* @return
*/
public Object getObject() {
return m_object;
}
}
--- NEW FILE: NoSuchReferenceException.java ---
/*
* Created on Aug 29, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.krysalis.ruper2.util.reference;
import org.krysalis.ruper2.RuperException;
import org.krysalis.ruper2.util.identity.GenericIdentifier;
import org.krysalis.ruper2.util.text.MessageConstants;
import org.krysalis.ruper2.util.text.Messages;
/**
* @author ajack
*/
public class NoSuchReferenceException extends RuperException {
public GenericIdentifier m_identifier = null;
public NoSuchReferenceException(GenericIdentifier identifier) {
//:TODO: Wire part of identifier (namespace prefix)
super(
Messages.getString(MessageConstants.NO_SUCH_REFERENCE, identifier));
m_identifier = identifier;
}
/**
* @return
*/
public GenericIdentifier getIdentifier() {
return m_identifier;
}
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
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.