org.objectweb.jorm.naming.lib
Class AbstractInheritFilteredPNamingContext

java.lang.Object
  extended byorg.objectweb.jorm.naming.lib.BasicPNamingContext
      extended byorg.objectweb.jorm.naming.lib.AbstractInheritFilteredPNamingContext
All Implemented Interfaces:
FilteredPNamingContext, PNameCoder, PNameManager, PNamingContext

public abstract class AbstractInheritFilteredPNamingContext
extends BasicPNamingContext
implements FilteredPNamingContext

This class is abstract implementation of the FilteredPNamingContext interface. The aim is to manage a tree of naming contexts. At each node a filter is able to say if a pname structure matches to the type represented by the PNamingContext. To use this class it is required - to override the right match and decodeXXX methods in according to the PARENT coding type, - to override the right encodeXXX methods in according to the coding type, - to implement the encodeString and decodeString method Example of overriding of a decodeXXX method: ============================================ public PName decodeAbstract(Object en) throws PExceptionNaming { //check coding type asked with the parent coding type if (parentCodingType != CTCOMPOSITE) { throw new PExceptionNaming("Decoding a composite name is not supported: " + en); } //obtain a PName with the 'en' parameter PName pn; if (en instanceof PName) { pn = (PName) en } else if (en instanceof ID1ID2PNG) { pn = new ID1ID2PName(this, ((ID1ID2PNG) en).pnGetId1(), ((ID1ID2PNG) en).pnGetId1()); } else if (en instanceof PNameGetter) { pn = new ID1ID2PName(this, ((PNameGetter) en).pnGetString("id1"), ((PNameGetter) en).pnGetLong("id2") ); } else { throw new PExceptionNaming("Impossible to decode this parameter: " + en); } // resolve the PName try { return resolve(null, pn); } catch (PException e) { throw new PExceptionNaming(e, "Impossible to resolve " + en); } } Example of overriding of a match method: ======================================== public boolean match(Object en) throws PExceptionNaming { if (parentCodingType != CTCOMPOSITE) { throw new PExceptionNaming("Decoding a composite name is not supported: " + en); } String id1 = ((FooPNG) en).getId1(); long id2 = ((FooPNG) en).getId2(); return id2 > 0 && "kangaroo".equals(id1) } Example of overriding of a encodeXXX method: ============================================ public Object encodeAbstract(PName pn) throws PExceptionNaming { return pn; //The PName is a PNameGetter }

Author:
S.Chassande-Barrioz, P.Dechamboux

Field Summary
protected  PBinder binder
          The Binder associated to the current type.
protected  int codingType
          The codingType of the current PNamingContext
protected  PNameGetterConverter converter
           
 
Fields inherited from class org.objectweb.jorm.naming.lib.BasicPNamingContext
ptype
 
Fields inherited from interface org.objectweb.jorm.naming.api.PNameCoder
CTBIGDECIMAL, CTBIGINTEGER, CTBYTE, CTBYTEARRAY, CTCHAR, CTCHARARRAY, CTCOMPOSITE, CTDATE, CTINT, CTLONG, CTOBYTE, CTOCHAR, CTOINT, CTOLONG, CTOSHORT, CTSHORT, CTSTRING, CTSYSTEM
 
Constructor Summary
AbstractInheritFilteredPNamingContext()
           
AbstractInheritFilteredPNamingContext(int codingType)
           
AbstractInheritFilteredPNamingContext(int codingType, PNameGetterConverter converter)
           
 
Method Summary
 void bindSubFPNC(FilteredPNamingContext fpnc)
          binds a sub filteredPNamingContext to the current.
 boolean codingSupported(int codingtype)
          It tests if a given coding type is supported by this naming context.
 java.lang.String encodeString(PName pn)
          The encodeString method produces an encoded representation of a PName within a naming context.
 PName export(java.lang.Object conn, java.lang.Object infoitem)
          It associates a PName to an information item within a naming context.
 PName export(java.lang.Object conn, java.lang.Object infoitem, java.lang.Object hints)
          It associates a PName to an information item within a naming context.
 PBinder getBinder()
           
 PNameGetterConverter getConverter()
           
 PName getNull()
          It yields a "null" representation of a name within this naming context.
 PName resolve(java.lang.Object conn, PName pn)
          It retrieves the information item associated to the given PName (if any exists).
 void setBinder(PBinder binder)
           
 void setCodingType(int codingType)
           
 void setConverter(PNameGetterConverter converter)
           
 void setNullPName(java.lang.Object o)
          It assignes a object which defines a null representation of a name within this naming context.
 void unbindSubFPNC(FilteredPNamingContext fpnc)
          Unbinds a sub PNC from its parent.
 void unexport(java.lang.Object conn, PName pn)
          It removes the PName and all the associated information within a naming context (i.e., the association between the PName and its information item).
 void unexport(java.lang.Object conn, PName pn, java.lang.Object hints)
          It removes the PName and all the associated information within a naming context (i.e., the association between the PName and its information item).
 
Methods inherited from class org.objectweb.jorm.naming.lib.BasicPNamingContext
decode, decodeAbstract, decodeBigDecimal, decodeBigInteger, decodeByte, decodeChar, decodeCharArray, decodeDate, decodeInt, decodeLong, decodeObyte, decodeOchar, decodeOint, decodeOlong, decodeOshort, decodeShort, encode, encodeAbstract, encodeBigDecimal, encodeBigInteger, encodeByte, encodeChar, encodeCharArray, encodeDate, encodeInt, encodeLong, encodeObyte, encodeOchar, encodeOint, encodeOlong, encodeOshort, encodeShort, getPType, setPType, supportCompositeField, supportDynamicComposite, supportStaticComposite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jorm.naming.api.FilteredPNamingContext
match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match
 
Methods inherited from interface org.objectweb.jorm.naming.api.PNameCoder
decode, decodeAbstract, decodeBigDecimal, decodeBigInteger, decodeByte, decodeChar, decodeCharArray, decodeDate, decodeInt, decodeLong, decodeObyte, decodeOchar, decodeOint, decodeOlong, decodeOshort, decodeShort, decodeString, encode, encodeAbstract, encodeBigDecimal, encodeBigInteger, encodeByte, encodeChar, encodeCharArray, encodeDate, encodeInt, encodeLong, encodeObyte, encodeOchar, encodeOint, encodeOlong, encodeOshort, encodeShort, getPType, setPType, supportCompositeField, supportDynamicComposite, supportStaticComposite
 

Field Detail

binder

protected PBinder binder
The Binder associated to the current type. A null value means the type is abstract.


codingType

protected int codingType
The codingType of the current PNamingContext


converter

protected PNameGetterConverter converter
Constructor Detail

AbstractInheritFilteredPNamingContext

public AbstractInheritFilteredPNamingContext()

AbstractInheritFilteredPNamingContext

public AbstractInheritFilteredPNamingContext(int codingType)

AbstractInheritFilteredPNamingContext

public AbstractInheritFilteredPNamingContext(int codingType,
                                             PNameGetterConverter converter)
Method Detail

getBinder

public PBinder getBinder()

setBinder

public void setBinder(PBinder binder)

setCodingType

public void setCodingType(int codingType)

getConverter

public PNameGetterConverter getConverter()

setConverter

public void setConverter(PNameGetterConverter converter)

bindSubFPNC

public void bindSubFPNC(FilteredPNamingContext fpnc)
Description copied from interface: FilteredPNamingContext
binds a sub filteredPNamingContext to the current. The implementation of this method must register the sub PNC and call the setParentCodingType method on this child.

Specified by:
bindSubFPNC in interface FilteredPNamingContext

unbindSubFPNC

public void unbindSubFPNC(FilteredPNamingContext fpnc)
Description copied from interface: FilteredPNamingContext
Unbinds a sub PNC from its parent.

Specified by:
unbindSubFPNC in interface FilteredPNamingContext

codingSupported

public boolean codingSupported(int codingtype)
Description copied from interface: PNameCoder
It tests if a given coding type is supported by this naming context.

Specified by:
codingSupported in interface PNameCoder
Overrides:
codingSupported in class BasicPNamingContext

getNull

public PName getNull()
Description copied from interface: PNameCoder
It yields a "null" representation of a name within this naming context.

Specified by:
getNull in interface PNameCoder
Returns:
The "null" PName associated with this naming context.

setNullPName

public void setNullPName(java.lang.Object o)
                  throws PException
Description copied from interface: PNameCoder
It assignes a object which defines a null representation of a name within this naming context.

Specified by:
setNullPName in interface PNameCoder
Parameters:
o - can be a PNameGetter (generic or generated), a pname, or a simple value (ex: Integer).
Throws:
PException

resolve

public PName resolve(java.lang.Object conn,
                     PName pn)
              throws PException
Description copied from interface: PNamingContext
It retrieves the information item associated to the given PName (if any exists).

Specified by:
resolve in interface PNamingContext
Parameters:
conn - The connection that can be used to access the data store.
pn - The PName to be looked up.
Returns:
The information item associated with the given PName within a naming context.
Throws:
PException

export

public PName export(java.lang.Object conn,
                    java.lang.Object infoitem)
             throws PException
Description copied from interface: PNameManager
It associates a PName to an information item within a naming context.

Specified by:
export in interface PNameManager
Parameters:
conn - The connection that can be used to access the data store.
infoitem - The information item that must be accessible through a PName within a naming context.
Returns:
The PName associated to the given information item.
Throws:
PException

export

public PName export(java.lang.Object conn,
                    java.lang.Object infoitem,
                    java.lang.Object hints)
             throws PException
Description copied from interface: PNameManager
It associates a PName to an information item within a naming context.

Specified by:
export in interface PNameManager
Parameters:
conn - The connection that can be used to access the data store.
infoitem - The information item that must be accessible through a PName within a naming context.
hints - Any information relevant for name creation.
Returns:
The PName associated to the given information item.
Throws:
PException

unexport

public void unexport(java.lang.Object conn,
                     PName pn)
              throws PException
Description copied from interface: PNameManager
It removes the PName and all the associated information within a naming context (i.e., the association between the PName and its information item).

Specified by:
unexport in interface PNameManager
Parameters:
conn - The connection that can be used to access the data store.
pn - A PName valid in this naming context. In case of a PBinder, export is done on a PBinding.
Throws:
PException

unexport

public void unexport(java.lang.Object conn,
                     PName pn,
                     java.lang.Object hints)
              throws PException
Description copied from interface: PNameManager
It removes the PName and all the associated information within a naming context (i.e., the association between the PName and its information item).

Specified by:
unexport in interface PNameManager
Parameters:
conn - The connection that can be used to access the data store.
pn - A PName valid in this naming context. In case of a PBinder, export is done on a PBinding.
hints - Any information relevant for name removing.
Throws:
PException

encodeString

public java.lang.String encodeString(PName pn)
                              throws PExceptionNaming
Description copied from interface: PNameCoder
The encodeString method produces an encoded representation of a PName within a naming context. The encoding format in the case of this method is a String.

Specified by:
encodeString in interface PNameCoder
Parameters:
pn - The PName to be encoded
Returns:
The String corresponding to the encoded representation.
Throws:
PExceptionNaming