Package org.glassfish.api.naming
Class SimpleJndiName
java.lang.Object
org.glassfish.api.naming.SimpleJndiName
- All Implemented Interfaces:
Serializable,Comparable<SimpleJndiName>
Value object for JNDI names used in GlassFish.
- Author:
- David Matejcek
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleJndiName(String jndiName) Does simple validation and creates the instance. -
Method Summary
Modifier and TypeMethodDescriptionchangePrefix(String newPrefix) Changes the simple JNDI name prefix.intcompareTo(SimpleJndiName other) booleanbooleanPrefix in this case is understood as any string in the forma:b/ora:orx://booleaninthashCode()booleanbooleanbooleanbooleanisEmpty()booleanbooleanbooleanbooleanstatic booleanisValidJndiName(String jndiName) Returns true if the parameter is not null and doesn't start with the "java:", or if it does, it must contain just one colon character.static SimpleJndiNamestatic SimpleJndiNameReturns the JNDI name without the prefix.removePrefix(String prefix) removeSuffix(String suffix) toName()toString()Returns the JNDI name.
-
Field Details
-
JNDI_CTX_CORBA
- See Also:
-
JNDI_CTX_JAVA
- See Also:
-
JNDI_CTX_JAVA_APP_NS_ID
- See Also:
-
JNDI_CTX_JAVA_APP
- See Also:
-
JNDI_CTX_JAVA_APP_ENV
- See Also:
-
JNDI_CTX_JAVA_COMPONENT_NS_ID
- See Also:
-
JNDI_CTX_JAVA_COMPONENT
- See Also:
-
JNDI_CTX_JAVA_COMPONENT_ENV
- See Also:
-
JNDI_CTX_JAVA_MODULE_NS_ID
- See Also:
-
JNDI_CTX_JAVA_MODULE
- See Also:
-
JNDI_CTX_JAVA_MODULE_ENV
- See Also:
-
JNDI_CTX_JAVA_GLOBAL_NS_ID
- See Also:
-
JNDI_CTX_JAVA_GLOBAL
- See Also:
-
-
Constructor Details
-
SimpleJndiName
Does simple validation and creates the instance.- Parameters:
jndiName- must not be null and if it is not acorbaname:jndi name, must not contain more than one colon.
-
-
Method Details
-
hasJavaPrefix
public boolean hasJavaPrefix()- Returns:
- true if the JNDI name starts with "java:"
-
hasCorbaPrefix
public boolean hasCorbaPrefix()- Returns:
- true if the JNDI name starts with "corbaname:"
-
isJavaGlobal
public boolean isJavaGlobal()- Returns:
- true if the JNDI name starts with "java:global".
-
isJavaApp
public boolean isJavaApp()- Returns:
- true if the JNDI name starts with "java:app".
-
isJavaModule
public boolean isJavaModule()- Returns:
- true if the JNDI name starts with "java:module".
-
isJavaComponent
public boolean isJavaComponent()- Returns:
- true if the JNDI name starts with "java:comp".
-
compareTo
- Specified by:
compareToin interfaceComparable<SimpleJndiName>
-
hashCode
public int hashCode() -
equals
-
isEmpty
public boolean isEmpty()- Returns:
- true if the JNDI name is an empty string
-
contains
- Parameters:
part- must not be null.- Returns:
- true if the JNDI name contains the parameter.
-
getPrefix
Prefix in this case is understood as any string in the forma:b/ora:orx://For JNDI names starting with "corbaname:" returns null.
- Returns:
- substring containing
:and ending by/
-
hasPrefix
- Parameters:
prefix- must not be null.- Returns:
- true if the JNDI name starts with the parameter.
-
hasSuffix
- Parameters:
suffix- must not be null.- Returns:
- true if the JNDI name ends with the parameter.
-
removePrefix
- Parameters:
prefix- can be null, then returns this instance unchanged.- Returns:
- new instance with the prefix removed or this instance unchanged if the prefix was not present.
-
removePrefix
Returns the JNDI name without the prefix. If there is no prefix, returns this instance unchanged.Prefix in this case is understood as any string in the form
a:b/ora:orx://For JNDI names starting with "corbaname:" returns this instance unchanged.
- Returns:
- new instance with the prefix removed or this instance unchanged, never null.
-
changePrefix
Changes the simple JNDI name prefix.Prefix in this case is understood as any string in the form
a:b/ora:orx://For JNDI names starting with "corbaname:" returns this instance unchanged.
If there is no prefix, just sets the new prefix. If the name is a Corba name doesn't do anything. If the name has
java:ccc/prefix or is an URL (protocol://xxx:8888/...), sets the new prefix instead of thejava:ccc/or theprotocol://- Parameters:
newPrefix- must end with the colon or slash.- Returns:
- new instance, never null.
- Throws:
IllegalArgumentException- if it is not possible to create valid JNDI name with the new prefix
-
removeSuffix
- Parameters:
suffix- can be null, then returns this instance unchanged.- Returns:
- new instance with the suffix removed or this instance unchanged if the suffix was not present.
-
toString
Returns the JNDI name. -
toName
- Returns:
CompositeNamerepresenting the same JNDI name.- Throws:
InvalidNameException- if the conversions was not possible.
-
isValidJndiName
Returns true if the parameter is not null and doesn't start with the "java:", or if it does, it must contain just one colon character.- Parameters:
jndiName- any string or null- Returns:
- true if the jndiName can be used in the constructor.
-
of
- Parameters:
name- can be null, then returns null.- Returns:
- null or a new instance of
SimpleJndiName.
-
of
- Parameters:
name- can be null, then returns null.- Returns:
- null or a new instance of
SimpleJndiName.
-