MCPcopy Create free account
hub / github.com/antlr/codebuff / writeObject

Method writeObject

output/java/1.4.15/Interpreter.java:713–746  ·  view source on GitHub ↗

Generic method to emit text for an object. It differentiates between templates, iterable objects, and plain old Java objects (POJOs)

(STWriter out, InstanceScope scope, Object o, String[] options)

Source from the content-addressed store, hash-verified

711 */
712
713 protected int writeObject(STWriter out, InstanceScope scope, Object o, String[] options) {
714 int n = 0;
715 if ( o==null ) {
716 if ( options !=null && options[Option.NULL.ordinal()]!=null ) {
717 o = options[Option.NULL.ordinal()];
718 }
719 else return 0;
720 }
721 if ( o instanceof ST) {
722 scope = new InstanceScope(scope, (ST)o);
723 if ( options !=null && options[Option.WRAP.ordinal()]!=null ) {
724 // if we have a wrap string, then inform writer it
725 // might need to wrap
726 try {
727 out.writeWrap(options[Option.WRAP.ordinal()]);
728 }
729 catch (IOException ioe) {
730 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe);
731 }
732 }
733 n = exec(out, scope);
734 }
735 else {
736 o = convertAnythingIteratableToIterator(scope, o); // normalize
737 try {
738 if ( o instanceof Iterator) n = writeIterator(out, scope, o, options);
739 else n = writePOJO(out, scope, o, options);
740 }
741 catch (IOException ioe) {
742 errMgr.IOError(scope.st, ErrorType.WRITE_IO_ERROR, ioe, o);
743 }
744 }
745 return n;
746 }
747
748 protected int writeIterator(STWriter out, InstanceScope scope, Object o, String[] options) throws IOException {
749 if ( o==null ) return 0;

Callers 3

writeObjectNoOptionsMethod · 0.95
writeIteratorMethod · 0.95

Calls 7

execMethod · 0.95
writeIteratorMethod · 0.95
writePOJOMethod · 0.95
ordinalMethod · 0.65
writeWrapMethod · 0.65
IOErrorMethod · 0.65

Tested by

no test coverage detected