当前位置: 首页>>代码示例>>Java>>正文


Java Attributes.size方法代码示例

本文整理汇总了Java中javax.naming.directory.Attributes.size方法的典型用法代码示例。如果您正苦于以下问题:Java Attributes.size方法的具体用法?Java Attributes.size怎么用?Java Attributes.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.naming.directory.Attributes的用法示例。


在下文中一共展示了Attributes.size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Rdn

import javax.naming.directory.Attributes; //导入方法依赖的package包/类
/**
 * Constructs an Rdn from the given attribute set. See
 * {@link javax.naming.directory.Attributes Attributes}.
 * <p>
 * The string attribute values are not interpreted as
 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
 * formatted RDN strings. That is, the values are used
 * literally (not parsed) and assumed to be unescaped.
 *
 * @param attrSet The non-null and non-empty attributes containing
 * type/value mappings.
 * @throws InvalidNameException If contents of <tt>attrSet</tt> cannot
 *          be used to construct a valid RDN.
 */
public Rdn(Attributes attrSet) throws InvalidNameException {
    if (attrSet.size() == 0) {
        throw new InvalidNameException("Attributes cannot be empty");
    }
    entries = new ArrayList<>(attrSet.size());
    NamingEnumeration<? extends Attribute> attrs = attrSet.getAll();
    try {
        for (int nEntries = 0; attrs.hasMore(); nEntries++) {
            RdnEntry entry = new RdnEntry();
            Attribute attr = attrs.next();
            entry.type = attr.getID();
            entry.value = attr.get();
            entries.add(nEntries, entry);
        }
    } catch (NamingException e) {
        InvalidNameException e2 = new InvalidNameException(
                                    e.getMessage());
        e2.initCause(e);
        throw e2;
    }
    sort(); // arrange entries for comparison
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Rdn.java

示例2: Rdn

import javax.naming.directory.Attributes; //导入方法依赖的package包/类
/**
 * Constructs an Rdn from the given attribute set. See
 * {@link javax.naming.directory.Attributes Attributes}.
 * <p>
 * The string attribute values are not interpreted as
 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
 * formatted RDN strings. That is, the values are used
 * literally (not parsed) and assumed to be unescaped.
 *
 * @param attrSet The non-null and non-empty attributes containing
 * type/value mappings.
 * @throws InvalidNameException If contents of {@code attrSet} cannot
 *          be used to construct a valid RDN.
 */
public Rdn(Attributes attrSet) throws InvalidNameException {
    if (attrSet.size() == 0) {
        throw new InvalidNameException("Attributes cannot be empty");
    }
    entries = new ArrayList<>(attrSet.size());
    NamingEnumeration<? extends Attribute> attrs = attrSet.getAll();
    try {
        for (int nEntries = 0; attrs.hasMore(); nEntries++) {
            RdnEntry entry = new RdnEntry();
            Attribute attr = attrs.next();
            entry.type = attr.getID();
            entry.value = attr.get();
            entries.add(nEntries, entry);
        }
    } catch (NamingException e) {
        InvalidNameException e2 = new InvalidNameException(
                                    e.getMessage());
        e2.initCause(e);
        throw e2;
    }
    sort(); // arrange entries for comparison
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:Rdn.java

示例3: decodeAttributes

import javax.naming.directory.Attributes; //导入方法依赖的package包/类
/**
 * Converts a JNDI Attributes into our LdapEntry object.
 *
 * @param dn The dn associated with the search.
 * @param attrNames an array of attribute names to be returned.
 *    If null, all available attributes are returned.
 * @param attrraw Then JNDI Attributes object resulting from the search.
 */

private LdapEntry decodeAttributes(
	String dn,
	String[] attrNames,
	Attributes attrraw)
throws LdapException
{
	LdapEntry entry = new LdapEntry( dn);
	if (bugs >= 1) prtln("\nReturned dn: " + dn);
	if (attrraw.size() == 0) {
		if (bugs >= 1) prtln("No attributes returned");
		if (attrNames != null) {
			// No attrs returned, but attr names were specified, so
			// we must return an empty array with just the attr names.
			entry.allocAttrs( attrNames.length);
			for (int iattr = 0; iattr < attrNames.length; iattr++) {
				entry.allocAttrsRow( iattr, 1);		// all rows just 1 long
				entry.setAttr( iattr, 0, attrNames[iattr]);
			}
		}
	}
	else {
		NamingEnumeration attrenum = attrraw.getAll();
		ArrayExc attrvec = fixEnum( attrenum);
		if (attrvec.exc != null)
			throw new LdapException("attrvec hidden exception", attrvec.exc);

		// If attrNames specified, use that format
		if (attrNames != null) {
			entry.allocAttrs( attrNames.length);

			// Fill in each requested attr name
			for (int iattr = 0; iattr < attrNames.length; iattr++) {
				// Search result set for matching name
				BasicAttribute foundattr = null;
				for (int ires = 0; ires < attrvec.vals.length; ires++) {
					BasicAttribute testattr = (BasicAttribute)
						attrvec.vals[ ires];
					if (testattr.getID().equals( attrNames[ iattr])) {
						foundattr = testattr;
						break;
					}
				}
				if (foundattr == null) {
					entry.allocAttrsRow( iattr, 1);		// just the attr name
					entry.setAttr( iattr, 0, attrNames[ iattr]);
				}
				else entry.setAttrsRow( iattr, decodeValues( foundattr));
			}
		}

		// Else no attrNames: return ALL attributes.
		else {
			entry.allocAttrs( attrvec.vals.length);

			// Sort the attributes by attribute ID (attribute name)
			Arrays.sort( attrvec.vals, new Comparator() {
				public int compare( Object obja, Object objb) {
					BasicAttribute attra = (BasicAttribute) obja;
					BasicAttribute attrb = (BasicAttribute) objb;
					return attra.getID().compareTo( attrb.getID());
				}
				public boolean equals( Object obj) { return false; }
			});
	
			for (int iattr = 0; iattr < attrvec.vals.length; iattr++) {
				entry.setAttrsRow( iattr, decodeValues(
					(BasicAttribute) attrvec.vals[ iattr]));
			}
		}
	}
	return entry;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:82,代码来源:LdapClient.java


注:本文中的javax.naming.directory.Attributes.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。