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


Java XStream.setupDefaultSecurity方法代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.XStream.setupDefaultSecurity方法的典型用法代碼示例。如果您正苦於以下問題:Java XStream.setupDefaultSecurity方法的具體用法?Java XStream.setupDefaultSecurity怎麽用?Java XStream.setupDefaultSecurity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.thoughtworks.xstream.XStream的用法示例。


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

示例1: loadArgs

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
private static List<ByteChameleon> loadArgs(String agentArguments) {
	XStream xStream = new XStream();

	Class<?>[] classes = new Class[] { ByteChameleon.class, Clazz.class, Method.class };
	XStream.setupDefaultSecurity(xStream);
	xStream.allowTypes(classes);

	xStream.processAnnotations(ByteChameleon.class);

	String[] files = agentArguments.split(",");
	List<ByteChameleon> list = new ArrayList<ByteChameleon>();

	for (String file : files) {
		list.add((ByteChameleon) xStream.fromXML(new File(file.replace(" ", ""))));
	}

	return list;
}
 
開發者ID:remartins,項目名稱:byte-chameleon,代碼行數:19,代碼來源:Agent.java

示例2: readXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Test
public void readXml() {
	XStream xStream = new XStream();
	
	Class<?>[] classes = new Class[] { ByteChameleon.class, Clazz.class, Method.class };
	XStream.setupDefaultSecurity(xStream);
	xStream.allowTypes(classes);
	xStream.processAnnotations(ByteChameleon.class);
	
	ByteChameleon byteChameleon = (ByteChameleon) xStream
			.fromXML(new File(AgentTest.class.getResource("/byte-chameleon.xml").getPath()));
	
	String[] result = new String[6];
	result[1] = "com.github.remartins.bytechameleon.Process";
	result[2] = "- replace : process";
	result[3] = "- replace : sum";
	result[4] = "- before : sum";
	result[5] = "- after : process";
	
	
	String[] real = byteChameleon.toString().split("\n");
	
	for (int i = 1; i < real.length; i++) {
		assertTrue(real[i].equals(result[i]));
	}
}
 
開發者ID:remartins,項目名稱:byte-chameleon,代碼行數:27,代碼來源:XStreamTest.java

示例3: create

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static XStream create(Class cls){
    XStream xStream = new XStream(new ThlwsXppDriver());
    XStream.setupDefaultSecurity(xStream);
    xStream.allowTypesByWildcard(new String[] {
            "org.thlws.payment.wechat.**"
    });
    xStream.alias("xml",cls);
    return  xStream;
}
 
開發者ID:thlws,項目名稱:payment-wechat,代碼行數:10,代碼來源:XStreamCreator.java

示例4: writeXml

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Test
public void writeXml() {
	
	Method method = new Method();
	method.setName("message");
	method.setParams("String");
	method.setType("before");
	method.setCode("System.out.println(\"Hello before call !!!\");");
	
	Clazz clazz = new Clazz();
	clazz.setName("Messenger");
	clazz.setMethods(new ArrayList<Method>());
	clazz.getMethods().add(method);

	ByteChameleon bc = new ByteChameleon();
	bc.setClasses(new ArrayList<Clazz>());
	bc.getClasses().add(clazz);
	
	XStream xStream = new XStream();
	Class<?>[] classes = new Class[] { ByteChameleon.class, Clazz.class, Method.class };
	XStream.setupDefaultSecurity(xStream);
	xStream.allowTypes(classes);
	xStream.processAnnotations(ByteChameleon.class);
	
	String result = xStream.toXML(bc).replaceAll("&quot;", "\"");
	String[] resultArray = result.split("\n");
	
	
	String[] padrao = {
			"<byte-chameleon>",
			"  <classes>",
			"    <class>",
			"      <name>Messenger</name>",
			"      <methods>",
			"        <method type=\"before\">",
			"          <name>message</name>",
			"          <params>String</params>",
			"          <code>System.out.println(\"Hello before call !!!\");</code>",
			"        </method>",
			"      </methods>",
			"    </class>",
			"  </classes>",
			"</byte-chameleon>"
	};
	
	assertEquals(padrao.length, resultArray.length);
	
	for (int i = 0; i < padrao.length - 1; i++) {
		assertTrue("Linha " + (i + 1) + ": " + resultArray[i], resultArray[i].equals(padrao[i]));
	}
	
	
}
 
開發者ID:remartins,項目名稱:byte-chameleon,代碼行數:54,代碼來源:XStreamTest.java


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