|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.ClassFactory<String,IDFactory.Instantiator>
net.jxta.id.IDFactory
public final class IDFactory
A factory class for creating new ID instances and for constructing ID instances from external representations such as strings or URIs.
When possible the factory will create IDs of the same ID Format as any base ids provided. For example, PipeIDs will be created to be the same ID Format as the PeerGroupID provided. Some ID constructors allow specification of "seed" information. Each ID Format may use this seed information as it chooses or may require seed information of a specific form. In some cases the seed information will be used literally as provided to construct the resulting ID, but ID Formats may also choose to ignore the seed information entirely, use it as random number generator seed values, etc. Consult the implementation documentation for the ID Formats of interest to see how the seed information is used by each ID Format.
ID
,
ClassFactory
,
JXTA Protocols Specification : IDsNested Class Summary | |
---|---|
static interface |
IDFactory.Instantiator
Interface for instantiators of IDs. |
static interface |
IDFactory.URIInstantiator
Deprecated. This interface formerly contained optional URI based construction methods. These have now been moved to the primary instantiator interface in preparation for the removal of the URL based interfaces. This interface will be removed in a future release. |
Method Summary | |
---|---|
static ID |
fromURI(URI source)
Construct a new ID instance from a JXTA ID contained in a URI. |
static ID |
fromURL(URL source)
Deprecated. Use of URLs for representing JXTA IDs and this method are deprecated. Convert to using fromURI( URI ) instead. |
protected Map<String,IDFactory.Instantiator> |
getAssocTable()
Used by ClassFactory methods to get the mapping of ID types to constructors. |
protected Class<String> |
getClassForKey()
Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type. |
protected Class<IDFactory.Instantiator> |
getClassOfInstantiators()
Used by ClassFactory methods to ensure that all of the instance classes which register with this factory have the correct base class |
static String |
getDefaultIDFormat()
Returns a String containing the name of the default ID Format. |
static URL |
jxtaURL(String uri)
Deprecated. You should convert code which creates JXTA IDs from strings to instead use {IDFactory.fromURI( new URI(String) )}. This method was only provided to overcome problems with registration of URL handlers in foreign class loader environments (Servlets, Applets, JNLP, etc.). |
static URL |
jxtaURL(String protocol,
String host,
String file)
Deprecated. You should convert code which creates JXTA IDs to instead use IDFactory.fromURI( new URI(...) ) . This method was only
provided to overcome problems with registration of URL handlers in
foreign class loader environments (Servlets, Applets, JNLP, etc.). |
static CodatID |
newCodatID(PeerGroupID groupID)
Creates a new CodatID Instance. |
static CodatID |
newCodatID(PeerGroupID groupID,
byte[] seed)
Creates a new CodatID instance. |
static CodatID |
newCodatID(PeerGroupID groupID,
byte[] seed,
InputStream in)
Creates a new CodatID instance. |
static CodatID |
newCodatID(PeerGroupID groupID,
InputStream in)
Creates a new CodatID instance. |
static ModuleClassID |
newModuleClassID()
Creates a new ModuleClassID instance. |
static ModuleClassID |
newModuleClassID(ModuleClassID baseClass)
Creates a new ModuleClassID instance. |
static ModuleClassID |
newModuleClassID(String idformat)
Creates a new ModuleClassID instance using the specified ID Format. |
static ModuleSpecID |
newModuleSpecID(ModuleClassID baseClass)
Creates a new ModuleSpecID instance. |
static PeerGroupID |
newPeerGroupID()
Creates a new PeerGroupID instance. |
static PeerGroupID |
newPeerGroupID(byte[] seed)
Creates a new PeerGroupID instance. |
static PeerGroupID |
newPeerGroupID(PeerGroupID parent)
Creates a new PeerGroupID instance with the specified parent group. |
static PeerGroupID |
newPeerGroupID(PeerGroupID parent,
byte[] seed)
Creates a new PeerGroupID instance with the specified parent group. |
static PeerGroupID |
newPeerGroupID(String idformat)
Creates a new PeerGroupID instance using the specified ID Format. |
static PeerGroupID |
newPeerGroupID(String idformat,
byte[] seed)
Creates a new PeerGroupID instance. |
static PeerID |
newPeerID(PeerGroupID groupID)
Creates a new PeerID instance. |
static PeerID |
newPeerID(PeerGroupID groupID,
byte[] seed)
Creates a new PeerID instance. |
static PipeID |
newPipeID(PeerGroupID groupID)
Creates a new PipeID instance. |
static PipeID |
newPipeID(PeerGroupID groupID,
byte[] seed)
Creates a new PipeID instance. |
boolean |
registerAssoc(String className)
Register a class with the factory from its class name. |
Methods inherited from class net.jxta.util.ClassFactory |
---|
getAvailableKeys, getEntrySet, getInstantiator, registerAssoc, registerFromFile, registerFromResources, registerFromString, registerProviders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
protected Map<String,IDFactory.Instantiator> getAssocTable()
getAssocTable
in class ClassFactory<String,IDFactory.Instantiator>
protected Class<String> getClassForKey()
getClassForKey
in class ClassFactory<String,IDFactory.Instantiator>
protected Class<IDFactory.Instantiator> getClassOfInstantiators()
getClassOfInstantiators
in class ClassFactory<String,IDFactory.Instantiator>
public boolean registerAssoc(String className)
registerAssoc
in class ClassFactory<String,IDFactory.Instantiator>
className
- The class name which will be registered.
public static String getDefaultIDFormat()
public static ID fromURI(URI source) throws URISyntaxException
source
- URI which will be decoded to create a new ID instance.
URISyntaxException
- If the URI provided is not a valid,
recognized JXTA URI.@Deprecated public static ID fromURL(URL source) throws MalformedURLException, UnknownServiceException
fromURI( URI )
instead.
source
- URI which will be decoded to create a new ID instance.
UnknownServiceException
- Is thrown if the URI provided is of a
format unrecognized by this JXTA implementation.
MalformedURLException
- Is thrown if the URI provided is not
a valid, recognized JXTA URI.public static CodatID newCodatID(PeerGroupID groupID)
groupID
- the group to which this content will belong.
Codat
public static CodatID newCodatID(PeerGroupID groupID, byte[] seed)
groupID
- the group to which this content will belong.seed
- The seed information which will be used in creating the
codatID. The seed information should be at least four bytes in length,
though longer values are better.
Codat
public static CodatID newCodatID(PeerGroupID groupID, InputStream in) throws IOException
groupID
- The group to which this ID will belong.in
- The InputStream from which the content hash is calculated.
The stream is read until EOF and then closed.
IOException
- I/O Error reading documentCodat
public static CodatID newCodatID(PeerGroupID groupID, byte[] seed, InputStream in) throws IOException
groupID
- The group to which this ID will belong.seed
- The seed information which will be used in creating the
codat ID. The seed information should be at least four bytes in length,
though longer values are better.in
- The InputStream from which the content hash is calculated.
The stream is read until EOF and then closed.
IOException
- I/O Error reading documentCodat
public static PeerID newPeerID(PeerGroupID groupID)
groupID
- the group to which this PeerID will belong.
PeerGroup
public static PeerID newPeerID(PeerGroupID groupID, byte[] seed)
groupID
- the group to which this PeerID will belong.seed
- The seed information which will be used in creating the
PeerID. The seed information should be at least four bytes in length,
though longer values are better.
PeerGroup
public static PeerGroupID newPeerGroupID()
PeerGroup
public static PeerGroupID newPeerGroupID(String idformat)
idformat
- The ID Format to be used for crating the Peer Group ID.
PeerGroup
public static PeerGroupID newPeerGroupID(byte[] seed)
seed
- The seed information which will be used in creating the
PeerGroupID. The seed information should be at least four bytes in length,
though longer values are better.
PeerGroup
public static PeerGroupID newPeerGroupID(String idformat, byte[] seed)
idformat
- The ID Format of the new Peer Group ID.seed
- The seed information which will be used in creating the
PeerGroupID. The seed information should be at least four bytes in length,
though longer values are better.
PeerGroup
public static PeerGroupID newPeerGroupID(PeerGroupID parent)
parent
- The group which will be the parent of this group.
PeerGroup
public static PeerGroupID newPeerGroupID(PeerGroupID parent, byte[] seed)
parent
- The group which will be the parent of this group.seed
- The seed information which will be used in creating the
PeerGroupID. The seed information should be at least four bytes in length,
though longer values are better.
PeerGroup
public static PipeID newPipeID(PeerGroupID groupID)
groupID
- The group to which this Pipe ID will belong.
public static PipeID newPipeID(PeerGroupID groupID, byte[] seed)
groupID
- the group to which this Pipe ID will belong.seed
- The seed information which will be used in creating the
pipeID. The seed information should be at least four bytes in length,
though longer values are better.
public static ModuleClassID newModuleClassID()
Module
public static ModuleClassID newModuleClassID(String idformat)
idformat
- The ID Format of the new ModuleClassID.
Module
public static ModuleClassID newModuleClassID(ModuleClassID baseClass)
baseClass
- The ModuleClassID which will be used as a base
class for this new role value instance.
Module
public static ModuleSpecID newModuleSpecID(ModuleClassID baseClass)
baseClass
- The ModuleClassID which will be used as a base
class for this new ModuleSpecID.
Module
@Deprecated public static URL jxtaURL(String protocol, String host, String file) throws MalformedURLException
IDFactory.fromURI( new URI(...) )
. This method was only
provided to overcome problems with registration of URL handlers in
foreign class loader environments (Servlets, Applets, JNLP, etc.).
new java.net.URL( )
to create URLs for use with IDFactory.
URL construction can cause classes to be loaded using the system
classLoader (JXTA IDs require the class
sun.net.www.protocol.urn.Handler
for Sun JVMs).
This class loading will fail in many environments such as web-servers,
servlet containers, application servers, or java web start where a user
class loader is used to load all JXTA resources.
protocol
- The protocol for this URLhost
- The host for this URLfile
- The file for this URL
MalformedURLException
- if an unknown protocol is specified.@Deprecated public static URL jxtaURL(String uri) throws MalformedURLException
new java.net.URL( )
to create URLs for use with IDFactory.
URL construction can cause classes to be loaded using the system
classLoader (JXTA IDs require the class
sun.net.www.protocol.urn.Handler
for Sun JVMs).
This class loading will fail in many environments such as web-servers,
servlet containers, application servers, or java web start where a user
class loader is used to load all JXTA resources.
uri
- The String
to parse as a URL.
MalformedURLException
- if an unknown protocol is specified.
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |