📄 idfactory.java
字号:
* @see net.jxta.peergroup.PeerGroup * @param idformat The ID Format to be used for crating the Peer Group ID. */ public static PeerGroupID newPeerGroupID( String idformat ) { Instantiator instantiator = (Instantiator) factory.getInstantiator( idformat ); return instantiator.newPeerGroupID( ); } /** * Creates a new PeerGroupID instance. A new PeerGroupID will be * generated using the provided seed information. The PeerGroupID will * be created using the default ID Format. * * <p/>This method allows you to create "Well-known" PeerGroupIDs. * This is similar to how the JXTA "World Peer Group" and "Net * Peer Group". "Well-known" IDs can be useful for common services * that need to do discovery without advertisements or for network * organization services. Because of the potential for ID collisions * and the difficulties with maintaining common service interfaces this * varient of PeerGroupID should be used with great caution and * pre-planning. * * @see net.jxta.peergroup.PeerGroup * * @param 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. * @return The newly created PeerGroupID. **/ public static PeerGroupID newPeerGroupID( byte [] seed ) { return newPeerGroupID( factory.idNewInstances, seed ); } /** * Creates a new PeerGroupID instance. A new PeerGroupID will be * generated using the provided seed information. The PeerGroupID will * be created using the default ID Format. * * <p/>This method allows you to create "Well-known" PeerGroupIDs. * This is similar to how the JXTA "World Peer Group" and "Net * Peer Group". "Well-known" IDs can be useful for common services * that need to do discovery without advertisements or for network * organization services. Because of the potential for ID collisions * and the difficulties with maintaining common service interfaces this * varient of PeerGroupID should be used with great caution and * pre-planning. * @return The newly created PeerGroupID. * @see net.jxta.peergroup.PeerGroup * @param idformat The ID Format of the new Peer Group ID. * @param 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. */ public static PeerGroupID newPeerGroupID( String idformat, byte [] seed ) { Instantiator instantiator = (Instantiator) factory.getInstantiator( idformat ); return instantiator.newPeerGroupID( seed ); } /** * Creates a new PeerGroupID instance with the specified parent group. * A new random peer group id will be generated. * * @see net.jxta.peergroup.PeerGroup * * @param parent The group which will be the parent of this group. * @return The newly created PeerGroupID. **/ public static PeerGroupID newPeerGroupID( PeerGroupID parent ) { String useFormat = parent.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newPeerGroupID( parent ); } /** * Creates a new PeerGroupID instance with the specified parent group. * A new PeerGroupID will be generated using the provided seed * information. * * <p/>This method allows you to create "Well-known" PeerGroupIDs. * This is similar to how the JXTA "World Peer Group" and "Net * Peer Group". "Well-known" IDs can be useful for common services * that need to do discovery without advertisements or for network * organization services. Because of the potential for ID collisions * and the difficulties with maintaining common service interfaces this * varient of PeerGroupID should be used with great caution and * pre-planning. * * @see net.jxta.peergroup.PeerGroup * * @param parent The group which will be the parent of this group. * @param 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. * @return The newly created PeerGroupID. **/ public static PeerGroupID newPeerGroupID( PeerGroupID parent, byte [] seed ) { String useFormat = parent.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newPeerGroupID( parent, seed ); } /** * Creates a new PipeID instance. A new random PipeID will be generated. * * @param groupID The group to which this Pipe ID will belong. * @return The newly created PipeID. **/ public static PipeID newPipeID( PeerGroupID groupID ) { String useFormat = groupID.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newPipeID( groupID ); } /** * Creates a new PipeID instance. A new pipe id will be generated with the * provided seed information. The Pipe ID will be a member of the provided * group. * * <p/>This varient of PipeID allows you to create "Well-known" pipes * within the context of diverse groups. This can be useful for common * services that need to do discovery without advertisements or for * network organization services. Because of the potential for ID * collisions and the difficulties with maintaining common service * interfaces this varient of PipeID should be used with great caution * and pre-planning. * * @param groupID the group to which this Pipe ID will belong. * @param 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. * @return the newly created PipeID. **/ public static PipeID newPipeID( PeerGroupID groupID, byte [] seed ) { String useFormat = groupID.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newPipeID( groupID, seed ); } /** * Creates a new ModuleClassID instance. A new random ModuleClassID will * be generated with a zero value role identifier. This form of * ModuleClassID is appropriate for cases where the module does not * need to be distinguished from other instances of the same Module. * The ModuleClassID will be created using the default ID Format. * * @see net.jxta.platform.Module * * @return The newly created ModuleClassID. **/ public static ModuleClassID newModuleClassID( ) { return newModuleClassID( factory.idNewInstances ); } /** * Creates a new ModuleClassID instance using the specified ID Format. * A new random ModuleClassID will be generated with a zero value role * identifier. This form of ModuleClassID is appropriate for cases * where the module does not need to be distinguished from other * instances of the same Module. * @return The newly created ModuleClassID. * @see net.jxta.platform.Module * @param idformat The ID Format of the new ModuleClassID. */ public static ModuleClassID newModuleClassID( String idformat ) { Instantiator instantiator = (Instantiator) factory.getInstantiator( idformat ); return instantiator.newModuleClassID( ); } /** * Creates a new ModuleClassID instance. A new random ModuleClassID will * be generated with a a random value role identifier and a base class of * the provided ModuleClassID. This form of ModuleClassID is * appropriate for cases where it is necessary to distinguish instances * of the same service interface. * * @see net.jxta.platform.Module * * @param baseClass The ModuleClassID which will be used as a base * class for this new role value instance. * @return The newly created ModuleClassID. **/ public static ModuleClassID newModuleClassID( ModuleClassID baseClass ) { String useFormat = baseClass.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newModuleClassID( baseClass ); } /** * Creates a new ModuleSpecID instance. A new random ModuleSpecID will * be generated. * * @see net.jxta.platform.Module * * @param baseClass The ModuleClassID which will be used as a base * class for this new ModuleSpecID. * @return The newly created ModuleSpecID. **/ public static ModuleSpecID newModuleSpecID( ModuleClassID baseClass ) { String useFormat = baseClass.getIDFormat(); // is the group netpg or worldpg? if( IDFormat.INSTANTIATOR.getSupportedIDFormat().equals( useFormat ) ) { useFormat = factory.idNewInstances; } Instantiator instantiator = (Instantiator) factory.getInstantiator( useFormat ); return instantiator.newModuleSpecID( baseClass ); } /** * This method should be used instead of using * <code>new java.net.URL( )</code> to create URLs for use with IDFactory. * URL construction can cause classes to be loaded using the system * classLoader (JXTA IDs require the class * <code>sun.net.www.protocol.urn.Handler</code> for Sun JVMs). * This class loading will fail in many enviroments such as web-servers, * servlet containers, application servers, or java web start where a user * class loader is used to load all JXTA resources. * * @deprecated You should convert code which creates JXTA IDs to instead * use <code>IDFactory.fromURI( new URI(...) )</code>. This method was only * provided to overcome problems with registration of URL handlers in * foreign class loader environments (Servlets, Applets, JNLP, etc.). * * @param protocol The protocol for this URL * @param host The host for this URL * @param file The file for this URL * @return a newly created URL for the resource specified. * @throws MalformedURLException if an unknown protocol is specified. **/ public static URL jxtaURL(String protocol, String host, String file) throws MalformedURLException { return new URL( protocol, host, -1, file, sun.net.www.protocol.urn.Handler.handler ); } /** * This method should be used instead of using * <code>new java.net.URL( )</code> to create URLs for use with IDFactory. * URL construction can cause classes to be loaded using the system * classLoader (JXTA IDs require the class * <code>sun.net.www.protocol.urn.Handler</code> for Sun JVMs). * This class loading will fail in many enviroments such as web-servers, * servlet containers, application servers, or java web start where a user * class loader is used to load all JXTA resources. * * @deprecated You should convert code which creates JXTA IDs from strings * to instead use <code>IDFactory.fromURI( new URI(String) )</code>. This * method was only provided to overcome problems with registration of URL * handlers in foreign class loader environments (Servlets, Applets, JNLP, * etc.). * * @param uri the <code>String</code> to parse as a URL. * @return a newly created URL for the resource specified. * @throws MalformedURLException if an unknown protocol is specified. **/ public static URL jxtaURL( String uri ) throws MalformedURLException { final String file = net.jxta.id.ID.URNNamespace + ":"; URL urlCnxt = jxtaURL(net.jxta.id.ID.URIEncodingName, "", file); return new URL(urlCnxt, uri); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -