本文整理汇总了Java中org.apache.harmony.jndi.provider.ldap.asn1.Utils.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.getBytes方法的具体用法?Java Utils.getBytes怎么用?Java Utils.getBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.jndi.provider.ldap.asn1.Utils
的用法示例。
在下文中一共展示了Utils.getBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
Object encoded;
if (value instanceof String) {
encoded = Utils.getBytes((String) value);
} else if (value instanceof AttributeTypeAndValuePair) {
AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value;
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(pair.getType());
objs[1] = pair.getValue();
if (objs[1] instanceof String) {
objs[1] = Utils.getBytes((String) objs[1]);
}
encoded = objs;
} else {
encoded = value;
}
values[0] = new ASN1ChoiceWrap.ChosenValue(index, encoded);
}
示例2: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
Object encoded;
if (value instanceof String) {
encoded = Utils.getBytes((String) value);
} else if (value instanceof AttributeTypeAndValuePair) {
AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value;
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(pair.getType());
objs[1] = pair.getValue();
if (objs[1] instanceof String) {
objs[1] = Utils.getBytes((String) objs[1]);
}
encoded = objs;
} else {
encoded = value;
}
values[0] = new ChosenValue(index, encoded);
}
示例3: test_encode_decode
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void test_encode_decode() throws NamingException {
String id = "test";
byte[] v1 = Utils.getBytes("value1");
byte[] v2 = Utils.getBytes("value2");
byte[] v3 = Utils.getBytes("value3");
LdapAttribute attr = new LdapAttribute(id, null);
attr.add(v1);
attr.add(v2);
attr.add(v3);
ASN1TestUtils.checkEncode(attr, LdapASN1Constant.Attribute);
Object[] encoded = new Object[2];
attr.encodeValues(encoded);
LdapAttribute decoded = new LdapAttribute("", null);
decoded.decodeValues(encoded);
assertEquals(attr.getID(), decoded.getID());
}
示例4: test_getExtendedResponse
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void test_getExtendedResponse() throws Exception {
MockExtendedRequest mockRequest = new MockExtendedRequest();
ExtendedOp op = new ExtendedOp(mockRequest);
assertSame(mockRequest, op.getExtendedRequest());
assertNull(op.getExtendedResponse());
Object[] values = new Object[] { ASN1Integer.fromIntValue(0),
Utils.getBytes(""), Utils.getBytes(""), null,
Utils.getBytes("hello"), Utils.getBytes("world") };
op.decodeValues(values);
LdapResult result = op.getResult();
assertNotNull(result);
assertEquals(0, result.getResultCode());
assertEquals("", result.getMachedDN());
assertEquals("", result.getErrorMessage());
assertNull(result.getReferrals());
ExtendedResponse response = op.getExtendedResponse();
assertTrue(response instanceof MockExtendedResponse);
}
示例5: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(entry);
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(ava.getType());
objs[1] = ava.getValue();
// FIXME: convert according to schema
values[1] = objs;
}
示例6: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] vs) {
vs[0] = Utils.getBytes(attrID);
List<Object> list = new ArrayList<Object>(this.values.size());
for (Object object : this.values) {
if (object instanceof String) {
String str = (String) object;
object = Utils.getBytes(str);
}
list.add(object);
}
vs[1] = list;
}
示例7: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(entry);
values[1] = Utils.getBytes(newrdn);
values[2] = Boolean.valueOf(deleteoldrdn);
if (newSuperior != null) {
values[3] = Utils.getBytes(newSuperior);
}
}
示例8: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = ASN1Integer.fromIntValue(resultCode);
values[1] = Utils.getBytes(machedDN);
values[2] = Utils.getBytes(errorMessage);
if (referrals != null) {
List<byte[]> refs = new ArrayList<byte[]>();
for (int i = 0; i < referrals.length; i++) {
refs.add(Utils.getBytes(referrals[i]));
}
values[3] = refs;
}
}
示例9: getRequest
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public ASN1Encodable getRequest() {
return new ASN1Encodable() {
public void encodeValues(Object[] values) {
values[0] = ASN1Integer.fromIntValue(3);
values[1] = Utils.getBytes(name);
values[2] = authChoice;
}
};
}
示例10: getLdapResult
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
private LdapResult getLdapResult(int errorCode, String message) {
LdapResult result = new LdapResult();
Object[] values = new Object[] { ASN1Integer.fromIntValue(errorCode),
Utils.getBytes(""), Utils.getBytes(message), null };
result.decodeValues(values);
return result;
}
示例11: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(entry);
values[1] = attrList;
}
示例12: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(request.getID());
values[1] = request.getEncodedValue();
}
示例13: test_binary_attribute
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void test_binary_attribute() throws Exception {
String id = "photo";
List<byte[]> valueList = new ArrayList<byte[]>();
byte[] bs = new byte[] { 0, 1, 2, 3, 4, 5 };
valueList.add(bs);
bs = Utils.getBytes("value");
valueList.add(bs);
Object[] values = new Object[] { Utils.getBytes(id), valueList };
LdapAttribute la = new LdapAttribute();
// 'photo' is binary attribute
la.decodeValues(values);
for (int i = 0; i < la.size(); ++i) {
assertTrue(la.get(i) instanceof byte[]);
}
id = "cn";
values = new Object[] { Utils.getBytes(id), valueList };
la = new LdapAttribute();
/*
* 'cn' is not binary attribute, but LdapAttribute.decodeValues()
* doesn't convert values to string, must call convertValueToString() to
* do it.
*/
la.decodeValues(values);
for (int i = 0; i < la.size(); ++i) {
assertTrue(la.get() instanceof byte[]);
}
la.convertValueToString();
for (int i = 0; i < la.size(); ++i) {
assertTrue(la.get() instanceof String);
}
id = "cn;binary";
values = new Object[] { Utils.getBytes(id), valueList };
la = new LdapAttribute();
// 'cn;binary' is binary attribute
la.decodeValues(values);
for (int i = 0; i < la.size(); ++i) {
assertTrue(la.get() instanceof byte[]);
}
}
示例14: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(mechanism);
values[1] = credentials;
}
示例15: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入方法依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(control.getID());
values[1] = Boolean.valueOf(control.isCritical());
values[2] = control.getEncodedValue();
}