本文整理匯總了Java中javax.naming.Name.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Name.toString方法的具體用法?Java Name.toString怎麽用?Java Name.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.Name
的用法示例。
在下文中一共展示了Name.toString方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getGroupBeanFromResult
import javax.naming.Name; //導入方法依賴的package包/類
public GroupBean getGroupBeanFromResult(Name name, Attributes attributes)
{
String id;
if( !Check.isEmpty(groupIdField) )
{
id = getValue(attributes, groupIdField);
}
else
{
id = name.toString();
}
if( config.isForceLowercaseIds() )
{
id = id.toLowerCase();
}
String groupname = getValue(attributes, groupNameField);
if( id.length() == 0 || groupname.length() == 0 )
{
return null;
}
return new DefaultGroupBean(id, groupname);
}
示例2: getNameInNamespace
import javax.naming.Name; //導入方法依賴的package包/類
@Override
public String getNameInNamespace() throws NamingException {
LocalContext ancestor = iParent;
if (ancestor == null) return "";
Name name = parse("");
name.add(iName);
while (ancestor != null && ancestor.iName != null) {
name.add(0, ancestor.iName);
ancestor = ancestor.iParent;
}
return name.toString();
}
示例3: fromName
import javax.naming.Name; //導入方法依賴的package包/類
/**
* Convert a {@link javax.naming.Name} to a Dn
*
* @param name The Name to convert
* @return A Dn
*/
public static Dn fromName( Name name )
{
try
{
return new Dn( name.toString() );
}
catch ( LdapInvalidDnException lide )
{
// TODO : check if we must throw an exception.
// Logically, the Name must be valid.
return null;
}
}
示例4: getObjectInstance
import javax.naming.Name; //導入方法依賴的package包/類
/**
* <p>Create and return a new <code>MemoryUserDatabase</code> instance
* that has been configured according to the properties of the
* specified <code>Reference</code>. If you instance can be created,
* return <code>null</code> instead.</p>
*
* @param obj The possibly null object containing location or
* reference information that can be used in creating an object
* @param name The name of this object relative to <code>nameCtx</code>
* @param nameCtx The context relative to which the <code>name</code>
* parameter is specified, or <code>null</code> if <code>name</code>
* is relative to the default initial context
* @param environment The possibly null environment that is used in
* creating this object
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?,?> environment)
throws Exception {
// We only know how to deal with <code>javax.naming.Reference</code>s
// that specify a class name of "org.apache.catalina.UserDatabase"
if ((obj == null) || !(obj instanceof Reference)) {
return (null);
}
Reference ref = (Reference) obj;
if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
return (null);
}
// Create and configure a MemoryUserDatabase instance based on the
// RefAddr values associated with this Reference
MemoryUserDatabase database = new MemoryUserDatabase(name.toString());
RefAddr ra = null;
ra = ref.get("pathname");
if (ra != null) {
database.setPathname(ra.getContent().toString());
}
ra = ref.get("readonly");
if (ra != null) {
database.setReadonly(Boolean.parseBoolean(ra.getContent().toString()));
}
// Return the configured database instance
database.open();
// Don't try something we know won't work
if (!database.getReadonly())
database.save();
return (database);
}
示例5: collectAllSubGroupFullNames
import javax.naming.Name; //導入方法依賴的package包/類
private void collectAllSubGroupFullNames(Set<String> results, DirContext ctx, Name parent)
{
final String fullname = parent.toString();
if( results.add(fullname) )
{
for( Name child : ldap.searchAllBases(ctx, getSubgroupsByMemberOfFilter(fullname),
new FullNameHitsCollector(), true) )
{
collectAllSubGroupFullNames(results, ctx, child);
}
}
}
示例6: getDistinguishedName
import javax.naming.Name; //導入方法依賴的package包/類
/**
* Returns the distinguished name of a search result.
*
* @param context Our DirContext
* @param base The base DN
* @param result The search result
* @return String containing the distinguished name
*/
protected String getDistinguishedName(DirContext context, String base, SearchResult result)
throws NamingException {
// Get the entry's distinguished name
NameParser parser = context.getNameParser("");
Name contextName = parser.parse(context.getNameInNamespace());
Name baseName = parser.parse(base);
// Bugzilla 32269
Name entryName = parser.parse(new CompositeName(result.getName()).get(0));
Name name = contextName.addAll(baseName);
name = name.addAll(entryName);
return name.toString();
}
示例7: getMyComponents
import javax.naming.Name; //導入方法依賴的package包/類
protected Name getMyComponents(Name name) throws NamingException {
if (name instanceof CompositeName) {
if (name.size() > 1)
throw new InvalidNameException(name.toString() + " has more components than namespace can handle");
return parse(name.get(0));
} else {
return name;
}
}
示例8: rename
import javax.naming.Name; //導入方法依賴的package包/類
@Override
public void rename(Name oldname, Name newname) throws NamingException {
if (oldname.isEmpty() || newname.isEmpty())
throw new InvalidNameException("Cannot rename empty name");
Name oldnm = getMyComponents(oldname);
Name newnm = getMyComponents(newname);
if (oldnm.size() != newnm.size())
throw new OperationNotSupportedException("Do not support rename across different contexts");
String oldatom = oldnm.get(0);
String newatom = newnm.get(0);
if (oldnm.size() == 1) {
if (iBindings.get(newatom) != null)
throw new NameAlreadyBoundException(newname.toString() + " is already bound");
Object oldBinding = iBindings.remove(oldatom);
if (oldBinding == null)
throw new NameNotFoundException(oldname.toString() + " not bound");
iBindings.put(newatom, oldBinding);
} else {
if (!oldatom.equals(newatom))
throw new OperationNotSupportedException("Do not support rename across different contexts");
Object inter = iBindings.get(oldatom);
if (!(inter instanceof Context))
throw new NotContextException(oldatom + " does not name a context");
((Context) inter).rename(oldnm.getSuffix(1), newnm.getSuffix(1));
}
}
示例9: getTargetContext
import javax.naming.Name; //導入方法依賴的package包/類
protected DirContextStringPair getTargetContext(String name)
throws NamingException {
if (cpe.getResolvedObj() == null)
throw (NamingException)cpe.fillInStackTrace();
Context ctx = NamingManager.getContext(cpe.getResolvedObj(),
cpe.getAltName(),
cpe.getAltNameCtx(),
env);
if (ctx instanceof DirContext)
return new DirContextStringPair((DirContext)ctx, name);
if (ctx instanceof Resolver) {
Resolver res = (Resolver)ctx;
ResolveResult rr = res.resolveToClass(name, DirContext.class);
// Reached a DirContext; return result.
DirContext dctx = (DirContext)rr.getResolvedObj();
Name tmp = rr.getRemainingName();
String remains = (tmp != null) ? tmp.toString() : "";
return (new DirContextStringPair(dctx, remains));
}
// Resolve all the way using lookup(). This may allow the operation
// to succeed if it doesn't require the penultimate context.
Object ultimate = ctx.lookup(name);
if (ultimate instanceof DirContext) {
return (new DirContextStringPair((DirContext)ultimate, ""));
}
throw (NamingException)cpe.fillInStackTrace();
}
示例10: getObjectInstance
import javax.naming.Name; //導入方法依賴的package包/類
/**
* <p>Create and return a new <code>MemoryUserDatabase</code> instance
* that has been configured according to the properties of the
* specified <code>Reference</code>. If you instance can be created,
* return <code>null</code> instead.</p>
*
* @param obj The possibly null object containing location or
* reference information that can be used in creating an object
* @param name The name of this object relative to <code>nameCtx</code>
* @param nameCtx The context relative to which the <code>name</code>
* parameter is specified, or <code>null</code> if <code>name</code>
* is relative to the default initial context
* @param environment The possibly null environment that is used in
* creating this object
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable environment)
throws Exception {
// We only know how to deal with <code>javax.naming.Reference</code>s
// that specify a class name of "org.apache.catalina.UserDatabase"
if ((obj == null) || !(obj instanceof Reference)) {
return (null);
}
Reference ref = (Reference) obj;
if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
return (null);
}
// Create and configure a MemoryUserDatabase instance based on the
// RefAddr values associated with this Reference
MemoryUserDatabase database = new MemoryUserDatabase(name.toString());
RefAddr ra = null;
ra = ref.get("pathname");
if (ra != null) {
database.setPathname(ra.getContent().toString());
}
// Return the configured database instance
database.open();
database.save();
return (database);
}
示例11: getObjectInstance
import javax.naming.Name; //導入方法依賴的package包/類
/**
* <p>
* Create and return a new <code>MemoryUserDatabase</code> instance that has
* been configured according to the properties of the specified
* <code>Reference</code>. If you instance can be created, return
* <code>null</code> instead.
* </p>
*
* @param obj
* The possibly null object containing location or reference
* information that can be used in creating an object
* @param name
* The name of this object relative to <code>nameCtx</code>
* @param nameCtx
* The context relative to which the <code>name</code> parameter
* is specified, or <code>null</code> if <code>name</code> is
* relative to the default initial context
* @param environment
* The possibly null environment that is used in creating this
* object
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
throws Exception {
// We only know how to deal with <code>javax.naming.Reference</code>s
// that specify a class name of "org.apache.catalina.UserDatabase"
if ((obj == null) || !(obj instanceof Reference)) {
return (null);
}
Reference ref = (Reference) obj;
if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
return (null);
}
// Create and configure a MemoryUserDatabase instance based on the
// RefAddr values associated with this Reference
MemoryUserDatabase database = new MemoryUserDatabase(name.toString());
RefAddr ra = null;
ra = ref.get("pathname");
if (ra != null) {
database.setPathname(ra.getContent().toString());
}
ra = ref.get("readonly");
if (ra != null) {
database.setReadonly(Boolean.parseBoolean(ra.getContent().toString()));
}
// Return the configured database instance
database.open();
// Don't try something we know won't work
if (!database.getReadonly())
database.save();
return (database);
}
示例12: composeName
import javax.naming.Name; //導入方法依賴的package包/類
@Override
public String composeName(String name, String prefix) throws NamingException {
Name result = composeName(new CompositeName(name), new CompositeName(prefix));
return result.toString();
}