Package flexjson

Examples of flexjson.TypeContext


      {
        context.setVisits(new ChainedSet(visits));
        context.getVisits().add(object);
        // traverse object
        BeanAnalyzer analyzer= BeanAnalyzer.analyze(resolveClass(object));
        TypeContext typeContext= context.writeOpenObject();

        context.writeName("@id");
        Integer objectId= getObjectId(object, context);
        context.getReferences().put(System.identityHashCode(object), objectId);
        context.write("" + objectId);

        context.writeComma();
        for (BeanProperty prop : analyzer.getProperties())
        {
          String name= prop.getName();
          path.enqueue(name);
          if (context.isIncluded(prop))
          {
            Object value= prop.getValue(object);
            //if (!context.getVisits().contains(value))
            {
              TransformerWrapper transformer= (TransformerWrapper) context.getTransformer(value);
              if ("class".equals(name)) //revisar esto!!!!
                transformer= new TransformerWrapper(new ClassTransformer());

              if (transformer == null)
                transformer= new TransformerWrapper(new NullTransformer());

              if ((transformer.getTransformer() instanceof ObjectTransformer) || !context.getVisits().contains(value))
              {
                if (!transformer.isInline())
                {
                  if (!typeContext.isFirst())
                    context.writeComma();
                  typeContext.setFirst(false);
                  context.writeName(name);
                }
                typeContext.setPropertyName(name);

                transformer.transform(value);
              }
            }
          }
View Full Code Here


    return context.isSerializingWithUniqueIds() ? System.identityHashCode(object) : context.ids++;
  }

  private void writeReference(Object object, JSONContext context)
  {
    TypeContext typeContext= context.writeOpenObject();
    context.writeName("@ref");
    context.write(context.getReferences().get(System.identityHashCode(object)) + "");
    context.writeCloseObject();
  }
View Full Code Here

public class ArrayTransformer extends AbstractTransformer
{

  public void transform(Object object)
  {
    TypeContext typeContext= getContext().writeOpenArray();
    int length= Array.getLength(object);
    for (int i= 0; i < length; ++i)
    {
      if (!typeContext.isFirst())
        getContext().writeComma();
      typeContext.setFirst(false);
      getContext().transform(Array.get(object, i));
    }
    getContext().writeCloseArray();
  }
View Full Code Here

TOP

Related Classes of flexjson.TypeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.