當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassDict類代碼示例

本文整理匯總了Java中net.razorvine.pickle.objects.ClassDict的典型用法代碼示例。如果您正苦於以下問題:Java ClassDict類的具體用法?Java ClassDict怎麽用?Java ClassDict使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClassDict類屬於net.razorvine.pickle.objects包,在下文中一共展示了ClassDict類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUnpickleCustomClassAsClassDict

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
@Test
public void testUnpickleCustomClassAsClassDict() throws IOException {
	byte[] pickled = new byte[] {
			(byte)128, 2, 99, 95, 95, 109, 97, 105, 110, 95, 95, 10, 67, 117, 115, 115, 115, 115, 115, 115,
			97, 122, 122, 10, 113, 0, 41, (byte)129, 113, 1, 125, 113, 2, 40, 85, 3, 97, 103, 101, 113, 3,
			75, 34, 85, 6, 118, 97, 108, 117, 101, 115, 113, 4, 93, 113, 5, 40, 75, 1, 75, 2, 75, 3,
			101, 85, 4, 110, 97, 109, 101, 113, 6, 85, 5, 72, 97, 114, 114, 121, 113, 7, 117, 98, 46};
	
	PyroSerializer ser = new PickleSerializer();
	ClassDict cd = (ClassDict) ser.deserializeData(pickled);
	assertEquals("__main__.Cussssssazz", cd.get("__class__"));
	assertEquals("Harry", cd.get("name"));
	assertEquals(34, cd.get("age"));
	ArrayList<Object> expected = new ArrayList<Object>() {{
		add(1);
		add(2);
		add(3);
	}};
	assertEquals(expected, cd.get("values"));
}
 
開發者ID:yncxcw,項目名稱:big-c,代碼行數:21,代碼來源:UnpicklerComplexTest.java

示例2: newObject

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
public ClassDict newObject(){
	Class<? extends ClassDict> clazz = getClazz();

	if(clazz == null){
		throw new RuntimeException();
	}

	try {
		try {
			Constructor<? extends ClassDict> namedConstructor = clazz.getConstructor(String.class, String.class);

			return namedConstructor.newInstance(getModule(), getName());
		} catch(NoSuchMethodException nsme){
			return clazz.newInstance();
		}
	} catch(IllegalAccessException | InstantiationException | InvocationTargetException e){
		throw new RuntimeException(e);
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:20,代碼來源:ObjectConstructor.java

示例3: formatClass

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String formatClass(Object object){

	if(object == null){
		return null;
	} // End if

	if(object instanceof ClassDict){
		ClassDict dict = (ClassDict)object;

		return "Python class " + getName(dict);
	}

	Class<?> clazz = object.getClass();

	return "Java class " + clazz.getName();
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:18,代碼來源:ClassDictUtil.java

示例4: construct

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
@Override
public ClassDict construct(Object[] args){

	if(args.length != 0){
		throw new PickleException(Arrays.deepToString(args));
	}

	return newObject();
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:10,代碼來源:ObjectConstructor.java

示例5: getName

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String getName(ClassDict dict){
	String clazz = (String)dict.get("__class__");

	if(clazz == null){
		throw new IllegalArgumentException();
	}

	return clazz;
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:11,代碼來源:ClassDictUtil.java

示例6: getSimpleName

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String getSimpleName(ClassDict dict){
	String name = getName(dict);

	int dot = name.lastIndexOf('.');
	if(dot > -1){
		return name.substring(dot + 1);
	}

	return name;
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:12,代碼來源:ClassDictUtil.java

示例7: testINST

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
@Test
public void testINST() throws PickleException, IOException {
	//INST           = b'i'   # build & push class instance
	ClassDict result = (ClassDict) U("(i__main__\nThing\n(dS'value'\nI32\nsb.");
	assertEquals("__main__.Thing", result.getClassName());
	assertEquals(32, result.get("value"));
}
 
開發者ID:irmen,項目名稱:Pyrolite,代碼行數:8,代碼來源:UnpickleOpcodesTest.java

示例8: testOBJ

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
@Test
public void testOBJ() throws PickleException, IOException {
	//OBJ            = b'o'   # build & push class instance
	ClassDict result = (ClassDict)U("\u0080\u0002(c__main__\nThing\no}U\u0005valueK sb.");
	assertEquals("__main__.Thing", result.getClassName());
	assertEquals(32, result.get("value"));
}
 
開發者ID:irmen,項目名稱:Pyrolite,代碼行數:8,代碼來源:UnpickleOpcodesTest.java

示例9: ObjectConstructor

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
public ObjectConstructor(String module, String name, Class<? extends ClassDict> clazz){
	setModule(module);
	setName(name);
	setClazz(clazz);
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:6,代碼來源:ObjectConstructor.java

示例10: getClazz

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
public Class<? extends ClassDict> getClazz(){
	return this.clazz;
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:4,代碼來源:ObjectConstructor.java

示例11: setClazz

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
private void setClazz(Class<? extends ClassDict> clazz){
	this.clazz = clazz;
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:4,代碼來源:ObjectConstructor.java

示例12: isObject

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
private boolean isObject(ClassDict dict){
	return ("__builtin__.object").equals(dict.get("__class__"));
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:5,代碼來源:ObjectConstructor.java

示例13: formatMember

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String formatMember(ClassDict dict, String name){
	String clazz = (String)dict.get("__class__");

	return (clazz + "." + name);
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:7,代碼來源:ClassDictUtil.java

示例14: formatProxyExample

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String formatProxyExample(Class<? extends ClassDict> proxyClazz, ClassDict dict){
	return (proxyClazz.getSimpleName() + "(" + ClassDictUtil.getSimpleName(dict) + "(...))");
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:5,代碼來源:ClassDictUtil.java

示例15: toString

import net.razorvine.pickle.objects.ClassDict; //導入依賴的package包/類
static
public String toString(ClassDict dict){
	StringBuffer sb = new StringBuffer();

	sb.append("\n{\n");

	String sep = "";

	List<? extends Map.Entry<String, ?>> entries = new ArrayList<>(dict.entrySet());

	Comparator<Map.Entry<String, ?>> comparator = new Comparator<Map.Entry<String, ?>>(){

		@Override
		public int compare(Map.Entry<String, ?> left, Map.Entry<String, ?> right){
			return (left.getKey()).compareToIgnoreCase(right.getKey());
		}
	};
	Collections.sort(entries, comparator);

	for(Map.Entry<String, ?> entry : entries){
		sb.append(sep);

		sep = "\n";

		String key = entry.getKey();
		Object value = entry.getValue();

		sb.append("\t" + key + "=" + value + (" // " + (value != null ? (value.getClass()).getName() : "N/A")));
	}

	sb.append("\n}\n");

	return sb.toString();
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:35,代碼來源:ClassDictUtil.java


注:本文中的net.razorvine.pickle.objects.ClassDict類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。