本文整理汇总了Java中javax.naming.directory.Attribute.size方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.size方法的具体用法?Java Attribute.size怎么用?Java Attribute.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.directory.Attribute
的用法示例。
在下文中一共展示了Attribute.size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeValues
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Get the values for the given attribute. If the attribute is null
* or does not contain any values, a zero length byte array is
* returned. NOTE that it is assumed that all values are byte arrays.
*/
private byte[][] getAttributeValues(Attribute attr)
throws NamingException {
byte[][] values;
if (attr == null) {
values = BB0;
} else {
values = new byte[attr.size()][];
int i = 0;
NamingEnumeration<?> enum_ = attr.getAll();
while (enum_.hasMore()) {
Object obj = enum_.next();
if (debug != null) {
if (obj instanceof String) {
debug.println("LDAPCertStore.getAttrValues() "
+ "enum.next is a string!: " + obj);
}
}
byte[] value = (byte[])obj;
values[i++] = value;
}
}
return values;
}
示例2: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
public Map getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
}
}
if (attributes == null)
return (Collections.EMPTY_MAP);
HashMap headerFields = new HashMap(attributes.size());
NamingEnumeration attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = (String)attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null) continue;
ArrayList attributeValueList = new ArrayList(attribute.size());
NamingEnumeration attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}
示例3: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
@Override
public Map<String,List<String>> getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
//Ignore
}
}
if (attributes == null)
return (Collections.emptyMap());
HashMap<String,List<String>> headerFields =
new HashMap<String,List<String>>(attributes.size());
NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null) continue;
ArrayList<String> attributeValueList =
new ArrayList<String>(attribute.size());
NamingEnumeration<?> attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}
示例4: getHeaderFields
import javax.naming.directory.Attribute; //导入方法依赖的package包/类
/**
* Returns an unmodifiable Map of the header fields.
*/
@Override
public Map<String, List<String>> getHeaderFields() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
// Ignore
}
}
if (attributes == null)
return (Collections.emptyMap());
HashMap<String, List<String>> headerFields = new HashMap<String, List<String>>(attributes.size());
NamingEnumeration<String> attributeEnum = attributes.getIDs();
try {
while (attributeEnum.hasMore()) {
String attributeID = attributeEnum.next();
Attribute attribute = attributes.get(attributeID);
if (attribute == null)
continue;
ArrayList<String> attributeValueList = new ArrayList<String>(attribute.size());
NamingEnumeration<?> attributeValues = attribute.getAll();
while (attributeValues.hasMore()) {
Object attrValue = attributeValues.next();
attributeValueList.add(getHeaderValueAsString(attrValue));
}
attributeValueList.trimToSize(); // should be a no-op if
// attribute.size() didn't
// lie
headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
}
} catch (NamingException ne) {
// Shouldn't happen
}
return Collections.unmodifiableMap(headerFields);
}