idfactory.java
来自「JXTA™ is a set of open, generalize」· Java 代码 · 共 1,211 行 · 第 1/4 页
JAVA
1,211 行
return instantiator.newPeerGroupID().intern(); } /** * 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 * variant 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).intern(); } /** * 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 * variant of PeerGroupID should be used with great caution and * pre-planning. * * @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. * @return The newly created PeerGroupID. */ public static PeerGroupID newPeerGroupID(String idformat, byte[] seed) { Instantiator instantiator = factory.getInstantiator(idformat); return instantiator.newPeerGroupID(seed).intern(); } /** * 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 = factory.getInstantiator(useFormat); return instantiator.newPeerGroupID(parent).intern(); } /** * 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 * variant 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 = factory.getInstantiator(useFormat); return instantiator.newPeerGroupID(parent, seed).intern(); } /** * 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 = factory.getInstantiator(useFormat); return instantiator.newPipeID(groupID).intern(); } /** * 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 variant 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 variant 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 = factory.getInstantiator(useFormat); return instantiator.newPipeID(groupID, seed).intern(); } /** * 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).intern(); } /** * 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. * * @see net.jxta.platform.Module * * @param idformat The ID Format of the new ModuleClassID. * @return The newly created ModuleClassID. */ public static ModuleClassID newModuleClassID(String idformat) { Instantiator instantiator = factory.getInstantiator(idformat); return instantiator.newModuleClassID().intern(); } /** * 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 = factory.getInstantiator(useFormat); return instantiator.newModuleClassID(baseClass).intern(); } /** * 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 = factory.getInstantiator(useFormat); return instantiator.newModuleSpecID(baseClass).intern(); } /** * This method should be used instead of using * {@code 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 * {@code 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. * * @deprecated You should convert code which creates JXTA IDs to instead * use {@code 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.). * * @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. */ @Deprecated 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( )} 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} 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. * * @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.). * * @param uri The {@code String} to parse as a URL. * @return a newly created URL for the resource specified. * @throws MalformedURLException if an unknown protocol is specified. */ @Deprecated 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 + =
减小字号Ctrl + -
显示快捷键?