Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 367 #370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,7 +209,7 @@ private void writeClassReaders(ModelClass modelClass, JClass jClass, boolean roo

sc = unmarshall.getSourceCode();

sc.add("Parser parser = new ParserImpl( new StreamReader( reader ) );");
sc.add("Parser parser = new ParserImpl( new StreamReader( reader ), new LoaderOptions() );");

sc.add("return " + readerMethodName + "( parser, strict );");

Expand Down Expand Up @@ -287,6 +287,7 @@ private void generateSnakeYamlReader() throws ModelloException, IOException {
jClass.addImport("org.yaml.snakeyaml.parser.ParserException");
jClass.addImport("org.yaml.snakeyaml.parser.ParserImpl");
jClass.addImport("org.yaml.snakeyaml.reader.StreamReader");
jClass.addImport("org.yaml.snakeyaml.LoaderOptions");
jClass.addImport("java.io.InputStream");
jClass.addImport("java.io.InputStreamReader");
jClass.addImport("java.io.IOException");
Expand Down Expand Up @@ -820,6 +821,8 @@ private void writeHelpers(JClass jClass) {

sc = method.getSourceCode();

sc.add("if (!(event instanceof ScalarEvent))");
sc.addIndented("return false;");
sc.add("String currentName = ( (ScalarEvent) event ).getValue();");

sc.add("");
Expand Down Expand Up @@ -855,9 +858,17 @@ private void writeHelpers(JClass jClass) {

sc.add("if ( strict )");

sc.add("{");
sc.indent();
sc.add("if ( event instanceof ScalarEvent )");
sc.add("{");
sc.addIndented(
"throw new ParserException( \"Unrecognised tag: '\" + ( (ScalarEvent) event ).getValue() + \"'\", event.getStartMark(), \"\", null );");
sc.add("} else {");
sc.addIndented(
"return ; // throw new ParserException( \"Unrecognised : '\" + event.getEventId() + \"'\", event.getStartMark(), \"\", null );");
sc.add("}");
sc.unindent();
sc.add("}");

sc.add("");
Expand Down
Expand Up @@ -291,7 +291,8 @@ private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloExce
sc.indent();

writeScalarKey(sc, fieldTagName);
sc.add("generator.emit( new SequenceStartEvent( null, null, true, null, null, false ) );");
sc.add(
"generator.emit( new SequenceStartEvent( null, null, true, null, null, FlowStyle.BLOCK ) );");

if (useJava5) {
sc.add("for ( " + toType + " o : " + value + " )");
Expand Down Expand Up @@ -330,7 +331,8 @@ private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloExce
writeScalarKey(sc, fieldTagName);

if (xmlAssociationMetadata.isMapExplode()) {
sc.add("generator.emit( new SequenceStartEvent( null, null, true, null, null, false ) );");
sc.add(
"generator.emit( new SequenceStartEvent( null, null, true, null, null, FlowStyle.BLOCK) );");
} else {
sc.add(
"generator.emit( new MappingStartEvent( null, null, true, null, null, FlowStyle.BLOCK ) );");
Expand All @@ -344,7 +346,7 @@ private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloExce
if (association.getType().equals(ModelDefault.PROPERTIES)) {
entryTypeBuilder.append("Object, Object");
} else {
entryTypeBuilder.append("String, ").append(association.getTo());
entryTypeBuilder.append("Object, ").append(association.getTo());
}

entryTypeBuilder.append('>');
Expand Down