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

Method writeObject

output/java/1.4.13/Interpreter.java:706–739  ·  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

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