本文整理匯總了Java中org.simpleframework.xml.stream.CamelCaseStyle類的典型用法代碼示例。如果您正苦於以下問題:Java CamelCaseStyle類的具體用法?Java CamelCaseStyle怎麽用?Java CamelCaseStyle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CamelCaseStyle類屬於org.simpleframework.xml.stream包,在下文中一共展示了CamelCaseStyle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCycle
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testCycle() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Registry registry = new Registry();
Address address = new Address("An Address");
Person person = new Person(address, "Niall", 30);
CycleStrategy referencer = new CycleStrategy();
RegistryStrategy strategy = new RegistryStrategy(registry, referencer);
Serializer serializer = new Persister(strategy, format);
Converter converter = new PersonConverter(serializer);
Club club = new Club(address);
club.addMember(person);
registry.bind(Person.class, converter);
serializer.write(club, System.out);
}
示例2: testPersonConverter
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testPersonConverter() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Registry registry = new Registry();
Person person = new Person("Niall", 30);
RegistryStrategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy, format);
Converter converter = new PersonConverter(serializer);
StringWriter writer = new StringWriter();
registry.bind(Person.class, converter);
PersonProfile profile = new PersonProfile(person);
serializer.write(profile, writer);
System.out.println(writer.toString());
PersonProfile read = serializer.read(PersonProfile.class, writer.toString());
assertEquals(read.person.name, "Niall");
assertEquals(read.person.age, 30);
}
示例3: testOtherStyle
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testOtherStyle() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
OtherCaseExample example = new OtherCaseExample("a", "b");
Persister persister = new Persister(format);
StringWriter writer = new StringWriter();
boolean exception = false;
try {
persister.write(example, writer);
}catch(Exception e) {
e.printStackTrace();
exception = true;
}
System.out.println(writer.toString());
assertFalse("No exception should be thrown with the elements are not the same name", exception);
}
示例4: testConverter
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testConverter() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Strategy cycle = new CycleStrategy();
Strategy strategy = new AnnotationStrategy(cycle);
Persister persister = new Persister(strategy, format);
List<ConverterDecorationExample> list = new ArrayList<ConverterDecorationExample>();
List<NormalExample> normal = new ArrayList<NormalExample>();
ConverterDecoration example = new ConverterDecoration(list, normal);
ConverterDecorationExample duplicate = new ConverterDecorationExample("duplicate");
NormalExample normalDuplicate = new NormalExample("duplicate");
list.add(duplicate);
list.add(new ConverterDecorationExample("a"));
list.add(new ConverterDecorationExample("b"));
list.add(new ConverterDecorationExample("c"));
list.add(duplicate);
list.add(new ConverterDecorationExample("d"));
list.add(duplicate);
normal.add(normalDuplicate);
normal.add(new NormalExample("1"));
normal.add(new NormalExample("2"));
normal.add(normalDuplicate);
persister.write(example, System.err);
}
示例5: testConverterWithPathInCamelStyle
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testConverterWithPathInCamelStyle() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Strategy strategy = new AnnotationStrategy();
Persister persister = new Persister(strategy, format);
ServerDetails primary = new ServerDetails("host1.blah.com", 4567, "PRIMARY");
ServerDetails secondary = new ServerDetails("host2.foo.com", 4567, "SECONDARY");
ServerDetailsReference reference = new ServerDetailsReference(primary, secondary);
StringWriter writer = new StringWriter();
persister.write(reference, writer);
System.out.println(writer);
ServerDetailsReference recovered = persister.read(ServerDetailsReference.class, writer.toString());
assertEquals(recovered.getPrimary().getHost(), reference.getPrimary().getHost());
assertEquals(recovered.getPrimary().getPort(), reference.getPrimary().getPort());
assertEquals(recovered.getPrimary().getName(), reference.getPrimary().getName());
assertEquals(recovered.getSecondary().getHost(), reference.getSecondary().getHost());
assertEquals(recovered.getSecondary().getPort(), reference.getSecondary().getPort());
assertEquals(recovered.getSecondary().getName(), reference.getSecondary().getName());
}
示例6: testCamelCaseStyle
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testCamelCaseStyle() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Persister persister = new Persister(format);
UnionListExample example = persister.read(UnionListExample.class, CAMEL_CASE_SOURCE);
List<Entry> entry = example.list;
assertEquals(entry.size(), 4);
assertEquals(entry.get(0).getClass(), IntegerEntry.class);
assertEquals(entry.get(0).foo(), 111);
assertEquals(entry.get(1).getClass(), DoubleEntry.class);
assertEquals(entry.get(1).foo(), 222.0);
assertEquals(entry.get(2).getClass(), StringEntry.class);
assertEquals(entry.get(2).foo(), "A");
assertEquals(entry.get(3).getClass(), StringEntry.class);
assertEquals(entry.get(3).foo(), "B");
assertEquals(example.entry.getClass(), IntegerEntry.class);
assertEquals(example.entry.foo(), 777);
persister.write(example, System.out);
validate(persister, example);
}
示例7: testConverter
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testConverter() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Registry registry = new Registry();
Customer customer = new Customer("Niall", "Some Place");
Envelope envelope = new Envelope(customer);
RegistryStrategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy, format);
Converter converter = new EnvelopeConverter(serializer);
registry.bind(Envelope.class, converter);
OrderItem order = new OrderItem(envelope);
serializer.write(order, System.out);
}
示例8: testArrayExample
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testArrayExample() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Persister persister = new Persister(format);
ArrayExample example = persister.read(ArrayExample.class, ARRAY);
assertEquals(example.getArray().length, 5);
assertEquals(example.getArray()[0], "entry one");
assertEquals(example.getArray()[1], "entry two");
assertEquals(example.getArray()[2], "entry three");
assertEquals(example.getArray()[3], "entry four");
assertEquals(example.getArray()[4], "entry five");
validate(persister, example);
}
示例9: testStyledPath
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testStyledPath() throws Exception {
Type type = new ClassType(PathParserTest.class);
Expression expression = new PathParser( "this/is/a/path", type, new Format(new CamelCaseStyle()));
String attributePath = expression.getAttribute("final");
assertEquals(attributePath, "This[1]/Is[1]/A[1]/Path[1]/@final");
String elementPath = expression.getElement("final");
assertEquals(elementPath, "This[1]/Is[1]/A[1]/Path[1]/Final[1]");
}
示例10: testStyledPathWithPrefixes
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testStyledPathWithPrefixes() throws Exception {
Type type = new ClassType(PathParserTest.class);
Expression expression = new PathParser("pre:this/is/a/pre:path", type, new Format(new CamelCaseStyle()));
String attributePath = expression.getAttribute("final");
assertEquals(attributePath, "pre:This[1]/Is[1]/A[1]/pre:Path[1]/@final");
String elementPath = expression.getElement("final");
assertEquals(elementPath, "pre:This[1]/Is[1]/A[1]/pre:Path[1]/Final[1]");
}
示例11: testStyleDup
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testStyleDup() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
StyleExample example = new StyleExample("a", "b");
Persister persister = new Persister(format);
StringWriter writer = new StringWriter();
persister.write(example, writer);
System.out.println(writer);
StyleExample restored = persister.read(StyleExample.class, writer.toString());
assertEquals(example.a, restored.a);
assertEquals(example.b, restored.b);
}
示例12: testStyle
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testStyle() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
CollisionExample example = new CollisionExample("a", "b");
Persister persister = new Persister(format);
StringWriter writer = new StringWriter();
boolean exception = false;
try {
persister.write(example, writer);
}catch(Exception e) {
e.printStackTrace();
exception = true;
}
assertTrue("Exception must be thrown when paths collide on case", exception);
}
示例13: testStyleDup
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testStyleDup() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
TextExample example = new TextExample("a", "b");
Persister persister = new Persister(format);
StringWriter writer = new StringWriter();
persister.write(example, writer);
System.out.println(writer);
TextExample restored = persister.read(TextExample.class, writer.toString());
assertEquals(example.a, restored.a);
assertEquals(example.b, restored.b);
}
示例14: testVisitor
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testVisitor() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Visitor visitor = new RenameVisitor();
VisitorStrategy strategy = new VisitorStrategy(visitor);
Persister renamePersister = new Persister(strategy);
Persister normalPersister = new Persister(format);
RenameExample example = new RenameExample("example name", "example value");
StringWriter renameWriter = new StringWriter();
StringWriter normalWriter = new StringWriter();
renamePersister.write(example, renameWriter);
normalPersister.write(example, normalWriter);
String renameResult = renameWriter.toString();
String normalResult = normalWriter.toString();
System.out.println(renameResult);
System.out.println(normalResult);
assertElementExists(renameResult, "/RENAMEEXAMPLE");
assertElementExists(renameResult, "/RENAMEEXAMPLE/NAME");
assertElementExists(renameResult, "/RENAMEEXAMPLE/VALUE");
assertElementHasValue(renameResult, "/RENAMEEXAMPLE/NAME", "example name");
assertElementHasValue(renameResult, "/RENAMEEXAMPLE/VALUE", "example value");
assertElementExists(normalResult, "/RenameExample");
assertElementExists(normalResult, "/RenameExample/Name");
assertElementExists(normalResult, "/RenameExample/Value");
assertElementHasValue(normalResult, "/RenameExample/Name", "example name");
assertElementHasValue(normalResult, "/RenameExample/Value", "example value");
}
示例15: testSerialization
import org.simpleframework.xml.stream.CamelCaseStyle; //導入依賴的package包/類
public void testSerialization() throws Exception {
Style style = new CamelCaseStyle();
Format format = new Format(style);
Persister camelPersister = new Persister(format);
Persister persister = new Persister();
ExampleAssembledType example = new ExampleAssembledType();
StringWriter writer = new StringWriter();
StringWriter camelWriter = new StringWriter();
example.setA("This is a");
example.setB("This is b");
example.setC("This is c");
example.setD("This is d");
example.setE("This is e");
example.setF("This is f");
example.setG("This is g");
example.setH("This is h");
example.setFirst("The first element");
example.setSecond("The second element");
example.setThird("The third element");
example.setFourth("The fourth element");
example.setFifth("The fifth element");
example.setSixth("The sixth element");
example.setSeventh("The seventh element");
example.setEight("The eight element");
example.setNinth("The ninth element");
example.setTenth("The tenth element");
camelPersister.write(example, System.err);
persister.write(example, System.out);
persister.write(example, writer);
camelPersister.write(example, camelWriter);
ExampleAssembledType recovered = persister.read(ExampleAssembledType.class, writer.toString());
ExampleAssembledType camelRecovered = camelPersister.read(ExampleAssembledType.class, camelWriter.toString());
assertEquals(recovered.a, example.a);
assertEquals(recovered.b, example.b);
assertEquals(recovered.c, example.c);
assertEquals(recovered.d, example.d);
assertEquals(recovered.e, example.e);
assertEquals(recovered.f, example.f);
assertEquals(recovered.g, example.g);
assertEquals(recovered.h, example.h);
assertEquals(recovered.first, example.first);
assertEquals(recovered.second, example.second);
assertEquals(recovered.third, example.third);
assertEquals(recovered.fourth, example.fourth);
assertEquals(recovered.fifth, example.fifth);
assertEquals(recovered.sixth, example.sixth);
assertEquals(recovered.seventh, example.seventh);
assertEquals(recovered.eight, example.eight);
assertEquals(recovered.ninth, example.ninth);
assertEquals(recovered.tenth, example.tenth);
assertEquals(camelRecovered.a, example.a);
assertEquals(camelRecovered.b, example.b);
assertEquals(camelRecovered.c, example.c);
assertEquals(camelRecovered.d, example.d);
assertEquals(camelRecovered.e, example.e);
assertEquals(camelRecovered.f, example.f);
assertEquals(camelRecovered.g, example.g);
assertEquals(camelRecovered.h, example.h);
assertEquals(camelRecovered.first, example.first);
assertEquals(camelRecovered.second, example.second);
assertEquals(camelRecovered.third, example.third);
assertEquals(camelRecovered.fourth, example.fourth);
assertEquals(camelRecovered.fifth, example.fifth);
assertEquals(camelRecovered.sixth, example.sixth);
assertEquals(camelRecovered.seventh, example.seventh);
assertEquals(camelRecovered.eight, example.eight);
assertEquals(camelRecovered.ninth, example.ninth);
assertEquals(camelRecovered.tenth, example.tenth);
validate(example, persister);
}