Examples of TypeContext


Examples of flexjson.TypeContext

import java.lang.reflect.Array;

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.increment();
            getContext().transform(Array.get(object, i));
        }
        getContext().writeCloseArray();
    }
View Full Code Here

Examples of flexjson.TypeContext

            return;
        }

        boolean setContext = false;

        TypeContext typeContext = getContext().peekTypeContext();
        String propertyName = typeContext != null ? typeContext.getPropertyName() : "";
        if(prefix.trim().equals("")) prefix = propertyName;

        if (typeContext == null || typeContext.getBasicType() != BasicType.OBJECT) {
            typeContext = getContext().writeOpenObject();
            setContext = true;
        }

        Date date = (Date) o;
        Calendar c = Calendar.getInstance();
        c.setTime(date);

        if (!typeContext.isFirst()) getContext().writeComma();
        typeContext.increment();
        getContext().writeName(fieldName("Month"));
        getContext().transform(c.get(Calendar.MONTH));

        getContext().writeComma();
        getContext().writeName(fieldName("Day"));
View Full Code Here

Examples of flexjson.TypeContext

        if( object == null ) {
            getContext().write("null");
            return;
        }
        String[] stringArr = (String[]) object;
        TypeContext typeContext = getContext().writeOpenArray();
        for (String item : stringArr) {
            if (!typeContext.isFirst()) getContext().writeComma();
            typeContext.increment();
            getContext().transform(item.toUpperCase());
        }
        getContext().writeCloseArray();

    }
View Full Code Here

Examples of flexjson.TypeContext

  {
    int identityHashCode= System.identityHashCode(object);

    JSONContext context= getContext();

    TypeContext typeContext= context.writeOpenObject();
    context.writeName("@id");
    context.write("" + identityHashCode);

    context.writeComma();
    context.writeName("class");
View Full Code Here

Examples of flexjson.TypeContext

{

  public void transform(Object object)
  {
    Iterable iterable= (Iterable) object;
    TypeContext typeContext= getContext().writeOpenArray();
    for (Object item : iterable)
    {
      if (!typeContext.isFirst())
        getContext().writeComma();
      typeContext.setFirst(false);
      getContext().transform(item);
    }
    getContext().writeCloseArray();
  }
View Full Code Here

Examples of flexjson.TypeContext

  {
    JSONContext context= getContext();
    Path path= context.getPath();
    Map value= (Map) object;

    TypeContext typeContext= getContext().writeOpenObject();
    for (Object key : value.keySet())
    {

      path.enqueue(key != null ? key.toString() : null);

      if (context.isIncluded(key != null ? key.toString() : null, value.get(key)))
      {

        TransformerWrapper transformer= (TransformerWrapper) context.getTransformer(value.get(key));

        if (!transformer.isInline())
        {
          if (!typeContext.isFirst())
            getContext().writeComma();
          typeContext.setFirst(false);
          if (key != null)
          {
            getContext().writeName(key.toString());
          }
          else
          {
            getContext().writeName(null);
          }
        }

        if (key != null)
        {
          typeContext.setPropertyName(key.toString());
        }
        else
        {
          typeContext.setPropertyName(null);
        }

        transformer.transform(value.get(key));

      }
View Full Code Here

Examples of flexjson.TypeContext

  {
    JSONContext context= getContext();
    Element element= (Element) object;
    String id= System.identityHashCode(element) + "";
    element.setAttribute("data-debug-id", id);
    TypeContext typeContext= context.writeOpenObject();

    context.writeName("id");
    context.writeQuoted(id);
    context.writeComma();
    context.writeName("class");
View Full Code Here

Examples of flexjson.TypeContext

  {
    JSONContext context= getContext();
    Path path= context.getPath();
    String name= ((Class) object).getName();
    name= name.replaceAll("_", ".");//TODO mejorar!!!
    TypeContext typeContext= context.writeOpenObject();

    context.writeName("name");
    context.writeQuoted(name);
    context.writeComma();
    context.writeName("class");
View Full Code Here

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

Examples of flexjson.TypeContext

    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
TOP
Copyright © 2018 www.massapi.com. 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.