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

Method writeObject

output/java/1.4.14/Interpreter.java:709–742  ·  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

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