krysalis-update/src/java/org/krysalis/depot/update/util/reference NoSuchReferenceException.java,NONE,1.1 ReferenceProxy.java,NONE,1.1 ReferenceTable.java,NONE,1.1 IReferenceable.java,NONE,1.1
Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:06:45 +0000
| Newsgroups | gmane.comp.krysalis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/krysalis/krysalis-update/src/java/org/krysalis/depot/update/util/reference
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/java/org/krysalis/depot/update/util/reference
Added Files:
NoSuchReferenceException.java ReferenceProxy.java
ReferenceTable.java IReferenceable.java
Log Message:
Copied from the apache incubator.
--- NEW FILE: ReferenceTable.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.util.reference;
import java.io.PrintWriter;
import java.util.HashMap;
import org.krysalis.depot.common.util.debug.DebugUtils;
import org.krysalis.depot.common.util.debug.Dumpable;
import org.krysalis.depot.update.util.identity.GenericIdentifier;
import org.krysalis.depot.update.util.identity.GenericNamespace;
/**
* @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(IReferenceable 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: NoSuchReferenceException.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.util.reference;
import org.krysalis.depot.update.UpdateException;
import org.krysalis.depot.update.util.identity.GenericIdentifier;
import org.krysalis.depot.update.util.text.MessageConstants;
import org.krysalis.depot.update.util.text.Messages;
/**
* @author ajack
*/
public class NoSuchReferenceException extends UpdateException {
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;
}
}
--- NEW FILE: ReferenceProxy.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.util.reference;
import org.krysalis.depot.update.util.identity.GenericIdentifier;
/**
* @author arb_jack
*/
public class ReferenceProxy implements IReferenceable {
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.depot.update.util.reference.Referenceable#getRefId()
*/
public GenericIdentifier getIdentifier() {
return m_identifier;
}
/**
* @return
*/
public Object getObject() {
return m_object;
}
}
--- NEW FILE: IReferenceable.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.util.reference;
import org.krysalis.depot.update.util.identity.IIdentifiable;
/**
* @author arb_jack
*/
public interface IReferenceable extends IIdentifiable {
}
-------------------------------------------------------
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/