本文整理匯總了Java中org.fosstrak.ale.util.SerializerUtil類的典型用法代碼示例。如果您正苦於以下問題:Java SerializerUtil類的具體用法?Java SerializerUtil怎麽用?Java SerializerUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SerializerUtil類屬於org.fosstrak.ale.util包,在下文中一共展示了SerializerUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decodeResult
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Override
protected void decodeResult(StringBuffer sb, Object result) {
if (result instanceof ArrayOfString) {
ArrayOfString resultStringArray = (ArrayOfString)result;
if (resultStringArray.getString().size() == 0) {
sb.append(m_guiText.getString("EmptyArray"));
} else {
for (String s : resultStringArray.getString()) {
sb.append(s);
sb.append("\n");
}
}
} else if (result instanceof LRSpec) {
CharArrayWriter writer = new CharArrayWriter();
try {
SerializerUtil.serializeLRSpec((LRSpec)result, writer);
} catch (Exception e) {
FosstrakAleClient.instance().showExceptionDialog(m_guiText.getString("SerializationExceptionMessage"));
}
sb.append(writer.toString());
}
}
示例2: test_W8
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
public void test_W8() throws Exception {
//step 1
//step 2
Thread.sleep(21000);
CCSpec ccspec2 = DeserializerUtil.deserializeCCSpec(getClass().getResourceAsStream("/ccspecs/CCSpec_W8_1.xml"));
CCReports ccreport2 = alecc.immediate(ccspec2);
CCReports expectedCcreports2 = DeserializerUtil.deserializeCCReports(getClass().getResourceAsStream("/ccreports/CCReports_W8_1.xml"));
StringWriter expectedSw2 = new StringWriter();
SerializerUtil.serializeCCReports(expectedCcreports2, expectedSw2);
String outExpectedString2 = expectedSw2.toString();
StringWriter sw2 = new StringWriter();
SerializerUtil.serializeCCReports(ccreport2, sw2);
String outString2 = sw2.toString();
Assert.assertEquals(outExpectedString2.substring(outExpectedString2.indexOf("<cmdReports")), outString2.substring(outString2.indexOf("<cmdReports")));
}
示例3: getXml
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* This method serializes ec reports into a xml representation.
*
* @param reports the report to be serialized.
* @return xml representation of the ec reports
* @throws ImplementationException if a implementation exception occurs
*/
protected String getXml(ECReports reports) throws ImplementationException {
CharArrayWriter writer = new CharArrayWriter();
try {
SerializerUtil.serializeECReports(reports, writer);
} catch (Exception e) {
LOG.debug("could not serialize the reports", e);
throw new ImplementationException("Unable to serialize reports.", e);
}
return writer.toString();
}
示例4: getPrettyXml
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* This method serializes ec reports into a well formed xml representation.
*
* @param reports to serialize
* @return well formed xml representation of the ec reports
* @throws ImplementationException if a implementation exception occurs
*/
protected String getPrettyXml(ECReports reports) throws ImplementationException {
CharArrayWriter writer = new CharArrayWriter();
try {
SerializerUtil.serializeECReports(reports, writer);
} catch (Exception e) {
throw new ImplementationException("Unable to serialize reports", e);
}
return writer.toString();
}
示例5: testReadECSpecs
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* test the creation of persisted ECSpecs.
* @throws Exception test failure.
*/
@Test
public void testReadECSpecs() throws Exception {
tempFolder.create();
File f = tempFolder.newFile("ecspec.xml");
final String fileName = f.getName();
// absolute path encodes the filename, thus remove it.
final String path = f.getAbsolutePath().replace(fileName, "");
ECSpec spec = ECElementsUtils.createECSpec();
SerializerUtil.serializeECSpec(spec, new FileOutputStream(f));
FileUtils fileUtils = EasyMock.createMock(FileUtils.class);
EasyMock.expect(fileUtils.getFilesName(path, FileUtils.FILE_ENDING_XML)).andReturn(Arrays.asList(new String[] { fileName } ));
EasyMock.replay(fileUtils);
PersistenceConfig persistenceConfig = EasyMock.createMock(PersistenceConfig.class);
EasyMock.expect(persistenceConfig.getRealPathECSpecDir()).andReturn(path).atLeastOnce();
EasyMock.replay(persistenceConfig);
ALE ale = EasyMock.createMock(ALE.class);
ale.define(EasyMock.eq("ecspec"), EasyMock.isA(ECSpec.class));
EasyMock.expectLastCall();
EasyMock.replay(ale);
ReadConfigImpl readConfig = new ReadConfigImpl();
readConfig.setFileUtils(fileUtils);
readConfig.setPersistenceConfig(persistenceConfig);
readConfig.setAle(ale);
// TEST
readConfig.readECSpecs();
EasyMock.verify(fileUtils);
EasyMock.verify(persistenceConfig);
EasyMock.verify(ale);
}
示例6: dataReceived
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* This method is invoked if the ReportHandler receives reports
*
* @param reports the ec reports which were received
*/
public void dataReceived(ECReports reports) {
try {
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeECReportsPretty(reports, writer);
ecReportArea.append(writer.toString());
ecReportArea.append("\n\n");
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: dataReceived
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* This method is invoked if the ReportHandler receives reports
*
* @param reports the ec reports which were received
*/
public void dataReceived(ECReports reports) {
try {
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeECReportsPretty(reports, writer);
if (m_accept.isSelected())
{
String key = (m_index++) + "-" + reports.getALEID() + "-" + reports.getSpecName();
ecReports.put(key, reports);
m_listModel.addElement(key);
if (m_update.isSelected())
{
m_ecReportArea.setText(writer.toString());
m_list.setSelectedIndex(0);
}
else
{
// fix for multiple elements autoselected if 0-th element clicked...
if (m_list.getSelectedIndices().length > 1)
{
m_list.setSelectedIndex(1);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例8: testSerializeECSpec
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeECSpec() throws Exception {
ECSpec ecSpec = createDummyECSpec();
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeECSpec(ecSpec, writer);
String str = writer.toString();
ECSpec ecSpec2 = DeserializerUtil.deserializeECSpec(new ByteArrayInputStream(str.getBytes()));
ensureSame(ecSpec, ecSpec2);
}
示例9: testSerializeECSpecWithOutputStream
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeECSpecWithOutputStream() throws Exception {
ECSpec ecSpec = createDummyECSpec();
ByteArrayOutputStream bous = new ByteArrayOutputStream();
SerializerUtil.serializeECSpec(ecSpec, bous);
String str = bous.toString();
ECSpec ecSpec2 = DeserializerUtil.deserializeECSpec(new ByteArrayInputStream(str.getBytes()));
ensureSame(ecSpec, ecSpec2);
}
示例10: testSerializeECSpecPretty
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeECSpecPretty() throws Exception {
ECSpec ecSpec = createDummyECSpec();
ByteArrayOutputStream bous = new ByteArrayOutputStream();
SerializerUtil.serializeECSpecPretty(ecSpec, bous);
String str = bous.toString();
ECSpec ecSpec2 = DeserializerUtil.deserializeECSpec(new ByteArrayInputStream(str.getBytes()));
ensureSame(ecSpec, ecSpec2);
}
示例11: testDeserializeECSpec
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
/**
* test the deserialization of the ECSpec from File.
* @throws Exception test failure.
*/
@Test
public void testDeserializeECSpec() throws Exception {
ECSpec ecSpec = createDummyECSpec();
File f = File.createTempFile("testDeserializeECSpec", ".xml");
FileOutputStream fof = new FileOutputStream(f);
SerializerUtil.serializeECSpec(ecSpec, fof);
fof.close();
ECSpec deserialized = DeserializerUtil.deserializeECSpec(f.getAbsolutePath());
ensureSame(ecSpec, deserialized);
}
示例12: testSerializeECReports
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeECReports() throws Exception {
ECReports ecReports = createDummyECReports();
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeECReports(ecReports, writer);
String str = writer.toString();
ECReports ecReports2 = DeserializerUtil.deserializeECReports(new ByteArrayInputStream(str.getBytes()));
ensureSame(ecReports, ecReports2);
}
示例13: testSerializeECReportsPretty
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeECReportsPretty() throws Exception {
ECReports ecReports = createDummyECReports();
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeECReportsPretty(ecReports, writer);
String str = writer.toString();
ECReports ecReports2 = DeserializerUtil.deserializeECReports(new ByteArrayInputStream(str.getBytes()));
ensureSame(ecReports, ecReports2);
}
示例14: testSerializeLRSpec
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeLRSpec() throws Exception {
LRSpec lrSpec = createDummyLRSpec();
CharArrayWriter writer = new CharArrayWriter();
SerializerUtil.serializeLRSpec(lrSpec, writer);
String str = writer.toString();
LRSpec lrSpec2 = DeserializerUtil.deserializeLRSpec(new ByteArrayInputStream(str.getBytes()));
ensureSame(lrSpec, lrSpec2);
}
示例15: testSerializeSetProperties
import org.fosstrak.ale.util.SerializerUtil; //導入依賴的package包/類
@Test
public void testSerializeSetProperties() throws Exception {
String fn = createTemporaryFileName();
SetProperties setProperties = createDummySetProperties();
SerializerUtil.serializeSetProperties(setProperties, fn);
SetProperties setProperties2 = DeserializerUtil.deserializeSetProperties(fn);
ensureSame(setProperties, setProperties2);
}