org.json.JSONWriter - java examples

Here are the examples of the java api org.json.JSONWriter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Writes a "create project" request.
 *
 * @param writer
 *            project writer.
 * @param project
 *            project to create.
 * @throws IllegalArgumentException
 *             if some project fields are not configured.
 * @throws JSONException
 *             if IO error occurs.
 */
public static void writeProject(JSONWriter writer, Project project) throws IllegalArgumentException, JSONException {
    /* Validate project */
    if (project.getName() == null)
        throw new IllegalArgumentException("Project name must be set to create a new project");
    if (project.getIdentifier() == null)
        throw new IllegalArgumentException("Project identifier must be set to create a new project");
    writeProject(project, writer);
}

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void addIfSet(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<?> property) throws JSONException {
    if (storage.isPropertySet(property)) {
        writer.key(jsonKeyName);
        writer.value(storage.get(property));
    }
}

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
static void writeTimeEntry(JSONWriter writer, TimeEntry timeEntry) throws JSONException {
    PropertyStorage storage = timeEntry.getStorage();
    addIfSet(writer, "id", storage, TimeEntry.DATABASE_ID);
    addIfSet(writer, "project_id", storage, TimeEntry.PROJECT_ID);
    addIfSet(writer, "issue_id", storage, TimeEntry.ISSUE_ID);
    addIfSet(writer, "user_id", storage, TimeEntry.USER_ID);
    addIfSet(writer, "activity_id", storage, TimeEntry.ACTIVITY_ID);
    addIfSet(writer, "hours", storage, TimeEntry.HOURS);
    addIfSet(writer, "comments", storage, TimeEntry.COMMENT);
    addIfSetShort2(writer, "spent_on", storage, TimeEntry.SPENT_ON);
    addIfSetFullDate(writer, "created_on", storage, TimeEntry.SPENT_ON);
    addIfSetFullDate(writer, "updated_on", storage, TimeEntry.SPENT_ON);
    writeCustomFields(writer, timeEntry.getCustomFields());
}

19 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds a list of objects.
 *
 * @param writer
 *            used writer.
 * @param field
 *            field to write.
 * @param items
 *            used items.
 * @param objWriter
 *            single object writer.
 */
public static <T> void addArrayIfNotEmpty(JSONWriter writer, String field, Collection<T> items, JsonObjectWriter<T> objWriter) throws JSONException {
    if (items == null || items.size() == 0)
        return;
    addCollection(writer, field, items, objWriter);
}

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void addIfSetFullDate(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<Date> property) throws JSONException {
    final SimpleDateFormat format = RedmineDateParser.FULL_DATE_FORMAT.get();
    addIfSet(writer, jsonKeyName, storage, property, format);
}

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeWatchers(JSONWriter writer, Collection<Watcher> watchers) throws JSONException {
    if (watchers == null || watchers.isEmpty()) {
        return;
    }
    writer.key("watcher_user_ids");
    writer.array();
    for (Watcher watcher : watchers) {
        if (watcher.getId() != null) {
            writer.value(watcher.getId().longValue());
        }
    }
    writer.endArray();
}

19 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
static void writeScalarValue(JSONWriter writer, Object object) throws JSONException {
    writer.value(object);
}

18 View Complete Implementation : EReferenceSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EReference obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    jw.key("changeable").value(obj.isChangeable());
    jw.key("volatile").value(obj.isVolatile());
    jw.key("transient").value(obj.isTransient());
    jw.key("defaultValueLiteral").value(obj.getDefaultValueLiteral());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("unsettable").value(obj.isUnsettable());
    jw.key("derived").value(obj.isDerived());
    jw.key("containment").value(obj.isContainment());
    jw.key("container").value(obj.isContainer());
    jw.key("resolveProxies").value(obj.isResolveProxies());
    serialized.put("EReference" + IdentificationResolver.getEReferenceId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
        jw.key("eContainingClreplaced");
        // else
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced())) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obj.getEContainingClreplaced(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced()));
        }
        jw.key("eOpposite");
        // else
        if (serialized.get("EReference" + IdentificationResolver.getEReferenceId(obj.getEOpposite())) == null) {
            webmapi.service.EReferenceSerializer.generateJSONObject(jw, obj.getEOpposite(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEReferenceId(obj.getEOpposite()));
        }
        jw.key("eReferenceType");
        // else
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obj.getEReferenceType())) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obj.getEReferenceType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEClreplacedId(obj.getEReferenceType()));
        }
        jw.key("eKeys");
        jw.array();
        for (org.eclipse.emf.ecore.EAttribute obji : obj.getEKeys()) {
            if (serialized.get("EAttribute" + IdentificationResolver.getEAttributeId(obji)) == null) {
                webmapi.service.EAttributeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
    }
    jw.endObject();
}

18 View Complete Implementation : ENamedElementContainerSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, webmapi.service.container.ENamedElementContainer obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    jw.key("EAttribute");
    jw.array();
    for (org.eclipse.emf.ecore.EAttribute obji : obj.getEAttribute()) {
        if (serialized.get("EAttribute" + IdentificationResolver.getEAttributeId(obji)) == null) {
            webmapi.service.EAttributeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EClreplaced");
    jw.array();
    for (org.eclipse.emf.ecore.EClreplaced obji : obj.getEClreplaced()) {
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obji)) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EClreplacedifier");
    jw.array();
    for (org.eclipse.emf.ecore.EClreplacedifier obji : obj.getEClreplacedifier()) {
        if (serialized.get("EClreplacedifier" + IdentificationResolver.getEClreplacedifierId(obji)) == null) {
            webmapi.service.EClreplacedifierSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EDataType");
    jw.array();
    for (org.eclipse.emf.ecore.EDataType obji : obj.getEDataType()) {
        if (serialized.get("EDataType" + IdentificationResolver.getEDataTypeId(obji)) == null) {
            webmapi.service.EDataTypeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EEnum");
    jw.array();
    for (org.eclipse.emf.ecore.EEnum obji : obj.getEEnum()) {
        if (serialized.get("EEnum" + IdentificationResolver.getEEnumId(obji)) == null) {
            webmapi.service.EEnumSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EEnumLiteral");
    jw.array();
    for (org.eclipse.emf.ecore.EEnumLiteral obji : obj.getEEnumLiteral()) {
        if (serialized.get("EEnumLiteral" + IdentificationResolver.getEEnumLiteralId(obji)) == null) {
            webmapi.service.EEnumLiteralSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EOperation");
    jw.array();
    for (org.eclipse.emf.ecore.EOperation obji : obj.getEOperation()) {
        if (serialized.get("EOperation" + IdentificationResolver.getEOperationId(obji)) == null) {
            webmapi.service.EOperationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EPackage");
    jw.array();
    for (org.eclipse.emf.ecore.EPackage obji : obj.getEPackage()) {
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obji)) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EParameter");
    jw.array();
    for (org.eclipse.emf.ecore.EParameter obji : obj.getEParameter()) {
        if (serialized.get("EParameter" + IdentificationResolver.getEParameterId(obji)) == null) {
            webmapi.service.EParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EReference");
    jw.array();
    for (org.eclipse.emf.ecore.EReference obji : obj.getEReference()) {
        if (serialized.get("EReference" + IdentificationResolver.getEReferenceId(obji)) == null) {
            webmapi.service.EReferenceSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EStructuralFeature");
    jw.array();
    for (org.eclipse.emf.ecore.EStructuralFeature obji : obj.getEStructuralFeature()) {
        if (serialized.get("EStructuralFeature" + IdentificationResolver.getEStructuralFeatureId(obji)) == null) {
            webmapi.service.EStructuralFeatureSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("ETypedElement");
    jw.array();
    for (org.eclipse.emf.ecore.ETypedElement obji : obj.getETypedElement()) {
        if (serialized.get("ETypedElement" + IdentificationResolver.getETypedElementId(obji)) == null) {
            webmapi.service.ETypedElementSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("ETypeParameter");
    jw.array();
    for (org.eclipse.emf.ecore.ETypeParameter obji : obj.getETypeParameter()) {
        if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obji)) == null) {
            webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeUpload(JSONWriter writer, Attachment attachment) throws JSONException {
    PropertyStorage storage = attachment.getStorage();
    addIfSet(writer, "token", storage, Attachment.TOKEN);
    addIfSet(writer, "filename", storage, Attachment.FILE_NAME);
    addIfSet(writer, "content_type", storage, Attachment.CONTENT_TYPE);
    addIfSet(writer, "description", storage, Attachment.DESCRIPTION);
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeGroup(final JSONWriter writer, Group group) throws JSONException {
    PropertyStorage storage = group.getStorage();
    addIfSet(writer, "id", storage, Group.ID);
    addIfSet(writer, "name", storage, Group.NAME);
}

18 View Complete Implementation : EAttributeSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EAttribute obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    jw.key("changeable").value(obj.isChangeable());
    jw.key("volatile").value(obj.isVolatile());
    jw.key("transient").value(obj.isTransient());
    jw.key("defaultValueLiteral").value(obj.getDefaultValueLiteral());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("unsettable").value(obj.isUnsettable());
    jw.key("derived").value(obj.isDerived());
    jw.key("iD").value(obj.isID());
    serialized.put("EAttribute" + IdentificationResolver.getEAttributeId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
        jw.key("eContainingClreplaced");
        // else
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced())) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obj.getEContainingClreplaced(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced()));
        }
        jw.key("eAttributeType");
        List<org.eclipse.emf.ecore.EDataType> eAttributeTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eAttributeTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEAttributeType() != null) {
            org.eclipse.emf.ecore.EDataType element = obj.getEAttributeType();
            if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eAttributeTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eAttributeTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EDataTypeContainer eAttributeTypeContainer = new webmapi.service.container.EDataTypeContainer(eAttributeTypeEDataType, eAttributeTypeEEnum);
        webmapi.service.EDataTypeContainerSerializer.generateJSONObject(jw, eAttributeTypeContainer, serialized, path, depth - 1);
    }
    jw.endObject();
}

18 View Complete Implementation : EDataTypeSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EDataType obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("instanceClreplacedName").value(obj.getInstanceClreplacedName());
    jw.key("instanceClreplaced").value(obj.getInstanceClreplaced());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("instanceTypeName").value(obj.getInstanceTypeName());
    jw.key("serializable").value(obj.isSerializable());
    serialized.put("EDataType" + IdentificationResolver.getEDataTypeId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("ePackage");
        // else
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obj.getEPackage())) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obj.getEPackage(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEPackageId(obj.getEPackage()));
        }
        jw.key("eTypeParameters");
        jw.array();
        for (org.eclipse.emf.ecore.ETypeParameter obji : obj.getETypeParameters()) {
            if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obji)) == null) {
                webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
    }
    jw.endObject();
}

18 View Complete Implementation : EOperationSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EOperation obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    serialized.put("EOperation" + IdentificationResolver.getEOperationId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
        jw.key("eContainingClreplaced");
        // else
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced())) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obj.getEContainingClreplaced(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced()));
        }
        jw.key("eTypeParameters");
        jw.array();
        for (org.eclipse.emf.ecore.ETypeParameter obji : obj.getETypeParameters()) {
            if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obji)) == null) {
                webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eParameters");
        jw.array();
        for (org.eclipse.emf.ecore.EParameter obji : obj.getEParameters()) {
            if (serialized.get("EParameter" + IdentificationResolver.getEParameterId(obji)) == null) {
                webmapi.service.EParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eExceptions");
        List<org.eclipse.emf.ecore.EClreplaced> eExceptionsEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eExceptionsEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eExceptionsEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        for (org.eclipse.emf.ecore.EClreplacedifier element : obj.getEExceptions()) {
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eExceptionsEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eExceptionsEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eExceptionsEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eExceptionsContainer = new webmapi.service.container.EClreplacedifierContainer(eExceptionsEClreplaced, eExceptionsEDataType, eExceptionsEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eExceptionsContainer, serialized, path, depth - 1);
        jw.key("eGenericExceptions");
        jw.array();
        for (org.eclipse.emf.ecore.EGenericType obji : obj.getEGenericExceptions()) {
            if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obji)) == null) {
                webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
    }
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void addIfSetShort2(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<Date> property) throws JSONException {
    final SimpleDateFormat format = RedmineDateParser.SHORT_DATE_FORMAT_V2.get();
    addIfSet(writer, jsonKeyName, storage, property, format);
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeCategory(final JSONWriter writer, IssueCategory category) throws JSONException {
    PropertyStorage storage = category.getStorage();
    writer.key("id");
    writer.value(category.getId());
    addIfSet(writer, "name", storage, IssueCategory.NAME);
    addIfSet(writer, "project_id", storage, IssueCategory.PROJECT_ID);
    addIfSet(writer, "replacedigned_to_id", storage, IssueCategory.replacedIGNEE_ID);
}

18 View Complete Implementation : ETypedElementSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.ETypedElement obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    serialized.put("ETypedElement" + IdentificationResolver.getETypedElementId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void addIfSet(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<Date> property, SimpleDateFormat format) throws JSONException {
    if (storage.isPropertySet(property)) {
        JsonOutput.add(writer, jsonKeyName, storage.get(property), format);
    }
}

18 View Complete Implementation : EDataTypeContainerSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, webmapi.service.container.EDataTypeContainer obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    jw.key("EDataType");
    jw.array();
    for (org.eclipse.emf.ecore.EDataType obji : obj.getEDataType()) {
        if (serialized.get("EDataType" + IdentificationResolver.getEDataTypeId(obji)) == null) {
            webmapi.service.EDataTypeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EEnum");
    jw.array();
    for (org.eclipse.emf.ecore.EEnum obji : obj.getEEnum()) {
        if (serialized.get("EEnum" + IdentificationResolver.getEEnumId(obji)) == null) {
            webmapi.service.EEnumSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.endObject();
}

18 View Complete Implementation : EParameterSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EParameter obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    serialized.put("EParameter" + IdentificationResolver.getEParameterId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
        jw.key("eOperation");
        // else
        if (serialized.get("EOperation" + IdentificationResolver.getEOperationId(obj.getEOperation())) == null) {
            webmapi.service.EOperationSerializer.generateJSONObject(jw, obj.getEOperation(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEOperationId(obj.getEOperation()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : ETypedElementContainerSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, webmapi.service.container.ETypedElementContainer obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    jw.key("EAttribute");
    jw.array();
    for (org.eclipse.emf.ecore.EAttribute obji : obj.getEAttribute()) {
        if (serialized.get("EAttribute" + IdentificationResolver.getEAttributeId(obji)) == null) {
            webmapi.service.EAttributeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EOperation");
    jw.array();
    for (org.eclipse.emf.ecore.EOperation obji : obj.getEOperation()) {
        if (serialized.get("EOperation" + IdentificationResolver.getEOperationId(obji)) == null) {
            webmapi.service.EOperationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EParameter");
    jw.array();
    for (org.eclipse.emf.ecore.EParameter obji : obj.getEParameter()) {
        if (serialized.get("EParameter" + IdentificationResolver.getEParameterId(obji)) == null) {
            webmapi.service.EParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EReference");
    jw.array();
    for (org.eclipse.emf.ecore.EReference obji : obj.getEReference()) {
        if (serialized.get("EReference" + IdentificationResolver.getEReferenceId(obji)) == null) {
            webmapi.service.EReferenceSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EStructuralFeature");
    jw.array();
    for (org.eclipse.emf.ecore.EStructuralFeature obji : obj.getEStructuralFeature()) {
        if (serialized.get("EStructuralFeature" + IdentificationResolver.getEStructuralFeatureId(obji)) == null) {
            webmapi.service.EStructuralFeatureSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.endObject();
}

18 View Complete Implementation : EObjectSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EObject obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    serialized.put("EObject" + IdentificationResolver.getEObjectId(obj), "t");
    if (depth > 0) {
    }
    jw.endObject();
}

18 View Complete Implementation : EClassifierContainerSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, webmapi.service.container.EClreplacedifierContainer obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    jw.key("EClreplaced");
    jw.array();
    for (org.eclipse.emf.ecore.EClreplaced obji : obj.getEClreplaced()) {
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obji)) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EDataType");
    jw.array();
    for (org.eclipse.emf.ecore.EDataType obji : obj.getEDataType()) {
        if (serialized.get("EDataType" + IdentificationResolver.getEDataTypeId(obji)) == null) {
            webmapi.service.EDataTypeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EEnum");
    jw.array();
    for (org.eclipse.emf.ecore.EEnum obji : obj.getEEnum()) {
        if (serialized.get("EEnum" + IdentificationResolver.getEEnumId(obji)) == null) {
            webmapi.service.EEnumSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.endObject();
}

18 View Complete Implementation : EEnumSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EEnum obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("instanceClreplacedName").value(obj.getInstanceClreplacedName());
    jw.key("instanceClreplaced").value(obj.getInstanceClreplaced());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("instanceTypeName").value(obj.getInstanceTypeName());
    jw.key("serializable").value(obj.isSerializable());
    serialized.put("EEnum" + IdentificationResolver.getEEnumId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("ePackage");
        // else
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obj.getEPackage())) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obj.getEPackage(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEPackageId(obj.getEPackage()));
        }
        jw.key("eTypeParameters");
        jw.array();
        for (org.eclipse.emf.ecore.ETypeParameter obji : obj.getETypeParameters()) {
            if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obji)) == null) {
                webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eLiterals");
        jw.array();
        for (org.eclipse.emf.ecore.EEnumLiteral obji : obj.getELiterals()) {
            if (serialized.get("EEnumLiteral" + IdentificationResolver.getEEnumLiteralId(obji)) == null) {
                webmapi.service.EEnumLiteralSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
    }
    jw.endObject();
}

18 View Complete Implementation : EEnumLiteralSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EEnumLiteral obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("value").value(obj.getValue());
    jw.key("instance").value(obj.getInstance());
    jw.key("literal").value(obj.getLiteral());
    serialized.put("EEnumLiteral" + IdentificationResolver.getEEnumLiteralId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eEnum");
        // else
        if (serialized.get("EEnum" + IdentificationResolver.getEEnumId(obj.getEEnum())) == null) {
            webmapi.service.EEnumSerializer.generateJSONObject(jw, obj.getEEnum(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEEnumId(obj.getEEnum()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : EFactorySerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EFactory obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    serialized.put("EFactory" + IdentificationResolver.getEFactoryId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("ePackage");
        // else
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obj.getEPackage())) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obj.getEPackage(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEPackageId(obj.getEPackage()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : EStructuralFeatureSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EStructuralFeature obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("ordered").value(obj.isOrdered());
    jw.key("unique").value(obj.isUnique());
    jw.key("lowerBound").value(obj.getLowerBound());
    jw.key("upperBound").value(obj.getUpperBound());
    jw.key("many").value(obj.isMany());
    jw.key("required").value(obj.isRequired());
    jw.key("changeable").value(obj.isChangeable());
    jw.key("volatile").value(obj.isVolatile());
    jw.key("transient").value(obj.isTransient());
    jw.key("defaultValueLiteral").value(obj.getDefaultValueLiteral());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("unsettable").value(obj.isUnsettable());
    jw.key("derived").value(obj.isDerived());
    serialized.put("EStructuralFeature" + IdentificationResolver.getEStructuralFeatureId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eType");
        List<org.eclipse.emf.ecore.EClreplaced> eTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eTypeEClreplaced, eTypeEDataType, eTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eTypeContainer, serialized, path, depth - 1);
        jw.key("eGenericType");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEGenericType())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEGenericType(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEGenericType()));
        }
        jw.key("eContainingClreplaced");
        // else
        if (serialized.get("EClreplaced" + IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced())) == null) {
            webmapi.service.EClreplacedSerializer.generateJSONObject(jw, obj.getEContainingClreplaced(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEClreplacedId(obj.getEContainingClreplaced()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
static void writeVersion(JSONWriter writer, Version version) throws JSONException {
    PropertyStorage storage = version.getStorage();
    addIfSet(writer, "id", storage, Version.DATABASE_ID);
    addIfSet(writer, "project_id", storage, Version.PROJECT_ID);
    addIfSet(writer, "name", storage, Version.NAME);
    addIfSet(writer, "description", storage, Version.DESCRIPTION);
    addIfSet(writer, "sharing", storage, Version.SHARING);
    addIfSet(writer, "status", storage, Version.STATUS);
    addIfSetShort2(writer, "due_date", storage, Version.DUE_DATE);
    addIfSetFullDate(writer, "created_on", storage, Version.CREATED_ON);
    addIfSetFullDate(writer, "updated_on", storage, Version.UPDATED_ON);
    writeCustomFields(writer, version.getCustomFields());
}

18 View Complete Implementation : EPackageSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EPackage obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("nsURI").value(obj.getNsURI());
    jw.key("nsPrefix").value(obj.getNsPrefix());
    serialized.put("EPackage" + IdentificationResolver.getEPackageId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eFactoryInstance");
        // else
        if (serialized.get("EFactory" + IdentificationResolver.getEFactoryId(obj.getEFactoryInstance())) == null) {
            webmapi.service.EFactorySerializer.generateJSONObject(jw, obj.getEFactoryInstance(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEFactoryId(obj.getEFactoryInstance()));
        }
        jw.key("eClreplacedifiers");
        List<org.eclipse.emf.ecore.EClreplaced> eClreplacedifiersEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eClreplacedifiersEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eClreplacedifiersEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        for (org.eclipse.emf.ecore.EClreplacedifier element : obj.getEClreplacedifiers()) {
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eClreplacedifiersEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eClreplacedifiersEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eClreplacedifiersEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eClreplacedifiersContainer = new webmapi.service.container.EClreplacedifierContainer(eClreplacedifiersEClreplaced, eClreplacedifiersEDataType, eClreplacedifiersEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eClreplacedifiersContainer, serialized, path, depth - 1);
        jw.key("eSubpackages");
        jw.array();
        for (org.eclipse.emf.ecore.EPackage obji : obj.getESubpackages()) {
            if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obji)) == null) {
                webmapi.service.EPackageSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eSuperPackage");
        // else
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obj.getESuperPackage())) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obj.getESuperPackage(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEPackageId(obj.getESuperPackage()));
        }
    }
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void writeCustomFields(JSONWriter writer, Collection<CustomField> customFields) throws JSONException {
    if (customFields == null || customFields.isEmpty()) {
        return;
    }
    writer.key("custom_field_values").object();
    for (CustomField field : customFields) {
        // see https://github.com/taskadapter/redmine-java-api/issues/54
        Object valueToWrite;
        if (field.isMultiple()) {
            valueToWrite = field.getValues();
        } else {
            valueToWrite = field.getValue();
        }
        writer.key(Integer.toString(field.getId())).value(valueToWrite);
    }
    writer.endObject();
}

18 View Complete Implementation : EStructuralFeatureContainerSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, webmapi.service.container.EStructuralFeatureContainer obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    jw.key("EAttribute");
    jw.array();
    for (org.eclipse.emf.ecore.EAttribute obji : obj.getEAttribute()) {
        if (serialized.get("EAttribute" + IdentificationResolver.getEAttributeId(obji)) == null) {
            webmapi.service.EAttributeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.key("EReference");
    jw.array();
    for (org.eclipse.emf.ecore.EReference obji : obj.getEReference()) {
        if (serialized.get("EReference" + IdentificationResolver.getEReferenceId(obji)) == null) {
            webmapi.service.EReferenceSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
        } else {
        // put a reference???
        }
    }
    jw.endArray();
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Converts object to a "simple" json.
 *
 * @param tag
 *            object tag.
 * @param object
 *            object to convert.
 * @param writer
 *            object writer.
 * @return object String representation.
 * @throws RedmineInternalError
 *             if conversion fails.
 */
public static <T> String toSimpleJSON(String tag, T object, JsonObjectWriter<T> writer) throws RedmineInternalError {
    final StringWriter swriter = new StringWriter();
    final JSONWriter jsWriter = new JSONWriter(swriter);
    try {
        jsWriter.object();
        jsWriter.key(tag);
        jsWriter.object();
        writer.write(jsWriter, object);
        jsWriter.endObject();
        jsWriter.endObject();
    } catch (JSONException e) {
        throw new RedmineInternalError("Unexpected JSONException", e);
    }
    return swriter.toString();
}

18 View Complete Implementation : EClassifierSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EClreplacedifier obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    jw.key("name").value(obj.getName());
    jw.key("instanceClreplacedName").value(obj.getInstanceClreplacedName());
    jw.key("instanceClreplaced").value(obj.getInstanceClreplaced());
    jw.key("defaultValue").value(obj.getDefaultValue());
    jw.key("instanceTypeName").value(obj.getInstanceTypeName());
    serialized.put("EClreplacedifier" + IdentificationResolver.getEClreplacedifierId(obj), "t");
    if (depth > 0) {
        jw.key("eAnnotations");
        jw.array();
        for (org.eclipse.emf.ecore.EAnnotation obji : obj.getEAnnotations()) {
            if (serialized.get("EAnnotation" + IdentificationResolver.getEAnnotationId(obji)) == null) {
                webmapi.service.EAnnotationSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("ePackage");
        // else
        if (serialized.get("EPackage" + IdentificationResolver.getEPackageId(obj.getEPackage())) == null) {
            webmapi.service.EPackageSerializer.generateJSONObject(jw, obj.getEPackage(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEPackageId(obj.getEPackage()));
        }
        jw.key("eTypeParameters");
        jw.array();
        for (org.eclipse.emf.ecore.ETypeParameter obji : obj.getETypeParameters()) {
            if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obji)) == null) {
                webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
    }
    jw.endObject();
}

18 View Complete Implementation : EGenericTypeSerializer.java
Copyright Eclipse Public License 1.0
Author : SOM-Research
public final static void generateJSONObject(JSONWriter jw, org.eclipse.emf.ecore.EGenericType obj, HashMap<String, String> serialized, StringBuffer path, int depth) {
    jw.object();
    if (obj == null) {
        jw.endObject();
        return;
    }
    // for each attribute
    serialized.put("EGenericType" + IdentificationResolver.getEGenericTypeId(obj), "t");
    if (depth > 0) {
        jw.key("eUpperBound");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getEUpperBound())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getEUpperBound(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getEUpperBound()));
        }
        jw.key("eTypeArguments");
        jw.array();
        for (org.eclipse.emf.ecore.EGenericType obji : obj.getETypeArguments()) {
            if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obji)) == null) {
                webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obji, serialized, path, depth - 1);
            } else {
            // put a reference???
            }
        }
        jw.endArray();
        jw.key("eRawType");
        List<org.eclipse.emf.ecore.EClreplaced> eRawTypeEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eRawTypeEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eRawTypeEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getERawType() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getERawType();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eRawTypeEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eRawTypeEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eRawTypeEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eRawTypeContainer = new webmapi.service.container.EClreplacedifierContainer(eRawTypeEClreplaced, eRawTypeEDataType, eRawTypeEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eRawTypeContainer, serialized, path, depth - 1);
        jw.key("eLowerBound");
        // else
        if (serialized.get("EGenericType" + IdentificationResolver.getEGenericTypeId(obj.getELowerBound())) == null) {
            webmapi.service.EGenericTypeSerializer.generateJSONObject(jw, obj.getELowerBound(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getEGenericTypeId(obj.getELowerBound()));
        }
        jw.key("eTypeParameter");
        // else
        if (serialized.get("ETypeParameter" + IdentificationResolver.getETypeParameterId(obj.getETypeParameter())) == null) {
            webmapi.service.ETypeParameterSerializer.generateJSONObject(jw, obj.getETypeParameter(), serialized, path, depth - 1);
        } else {
            jw.value(IdentificationResolver.getETypeParameterId(obj.getETypeParameter()));
        }
        jw.key("eClreplacedifier");
        List<org.eclipse.emf.ecore.EClreplaced> eClreplacedifierEClreplaced = new ArrayList<org.eclipse.emf.ecore.EClreplaced>();
        List<org.eclipse.emf.ecore.EDataType> eClreplacedifierEDataType = new ArrayList<org.eclipse.emf.ecore.EDataType>();
        List<org.eclipse.emf.ecore.EEnum> eClreplacedifierEEnum = new ArrayList<org.eclipse.emf.ecore.EEnum>();
        if (obj.getEClreplacedifier() != null) {
            org.eclipse.emf.ecore.EClreplacedifier element = obj.getEClreplacedifier();
            if (element instanceof org.eclipse.emf.ecore.EClreplaced) {
                eClreplacedifierEClreplaced.add((org.eclipse.emf.ecore.EClreplaced) element);
            } else if (element instanceof org.eclipse.emf.ecore.EEnum) {
                eClreplacedifierEEnum.add((org.eclipse.emf.ecore.EEnum) element);
            } else if (element instanceof org.eclipse.emf.ecore.EDataType) {
                eClreplacedifierEDataType.add((org.eclipse.emf.ecore.EDataType) element);
            }
        }
        webmapi.service.container.EClreplacedifierContainer eClreplacedifierContainer = new webmapi.service.container.EClreplacedifierContainer(eClreplacedifierEClreplaced, eClreplacedifierEDataType, eClreplacedifierEEnum);
        webmapi.service.EClreplacedifierContainerSerializer.generateJSONObject(jw, eClreplacedifierContainer, serialized, path, depth - 1);
    }
    jw.endObject();
}

18 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void addIfSetIdentifiable(JSONWriter writer, String jsonKeyName, PropertyStorage storage, Property<? extends Identifiable> property) throws JSONException {
    if (storage.isPropertySet(property)) {
        final Identifiable propertyValue = storage.get(property);
        writer.key(jsonKeyName);
        if (propertyValue != null) {
            writer.value(propertyValue.getId());
        } else {
            writer.value(null);
        }
    }
}

17 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
private static void writeProjectTrackers(JSONWriter writer, Project project) throws JSONException {
    // skip if storage is not already set to allow new projects get the redmine system default trackers
    PropertyStorage storage = project.getStorage();
    if (storage.isPropertySet(Project.TRACKERS)) {
        Collection<Integer> trackerIds = new ArrayList<>();
        for (Tracker tracker : project.getTrackers()) trackerIds.add(tracker.getId());
        JsonOutput.addScalarArray(writer, "tracker_ids", trackerIds, RedmineJSONBuilder::writeScalarValue);
    }
}

17 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
static void writeRelation(JSONWriter writer, IssueRelation relation) throws JSONException {
    PropertyStorage storage = relation.getStorage();
    addIfSet(writer, "issue_to_id", storage, IssueRelation.ISSUE_TO_ID);
    addIfSet(writer, "relation_type", storage, IssueRelation.RELATION_TYPE);
    addIfSet(writer, "delay", storage, IssueRelation.DELAY);
}

17 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds an object if object is not null.
 *
 * @param writer
 *            object writer.
 * @param field
 *            field writer.
 * @param value
 *            value writer.
 * @param objWriter
 *            object value writer.
 * @throws JSONException
 *             if io error occurs.
 */
public static <T> void addIfNotNull(JSONWriter writer, String field, T value, JsonObjectWriter<T> objWriter) throws JSONException {
    if (value == null)
        return;
    writer.key(field);
    writer.object();
    objWriter.write(writer, value);
    writer.endObject();
}

17 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeProject(Project project, final JSONWriter writer) throws JSONException {
    PropertyStorage storage = project.getStorage();
    addIfSet(writer, "id", storage, Project.DATABASE_ID);
    addIfSet(writer, "identifier", storage, Project.STRING_IDENTIFIER);
    addIfSet(writer, "name", storage, Project.NAME);
    addIfSet(writer, "description", storage, Project.DESCRIPTION);
    addIfSet(writer, "homepage", storage, Project.HOMEPAGE);
    addIfSetFullDate(writer, "created_on", storage, Project.CREATED_ON);
    addIfSetFullDate(writer, "updated_on", storage, Project.UPDATED_ON);
    writeCustomFields(writer, project.getCustomFields());
    addIfSet(writer, "parent_id", storage, Project.PARENT_DATABASE_ID);
    addIfSet(writer, "status", storage, Project.STATUS);
    addIfSet(writer, "is_public", storage, Project.PUBLIC);
    addIfSet(writer, "inherit_members", storage, Project.INHERIT_MEMBERS);
    writeProjectTrackers(writer, project);
}

17 View Complete Implementation : MapPrinterServlet.java
Copyright BSD 2-Clause "Simplified" License
Author : mapfish
/**
 * To get (in JSON) the information about the available formats and CO.
 *
 * @param jsonpCallback if given the result is returned with a function call wrapped around it
 * @param listAppsResponse the response object
 */
@RequestMapping(value = LIST_APPS_URL, method = RequestMethod.GET)
public final void listAppIds(@RequestParam(value = "jsonp", defaultValue = "") final String jsonpCallback, final HttpServletResponse listAppsResponse) throws ServletException, IOException {
    MDC.remove(Processor.MDC_JOB_ID_KEY);
    setCache(listAppsResponse);
    Set<String> appIds = this.printerFactory.getAppIds();
    setContentType(listAppsResponse, jsonpCallback);
    try (PrintWriter writer = listAppsResponse.getWriter()) {
        appendJsonpCallback(jsonpCallback, writer);
        JSONWriter json = new JSONWriter(writer);
        try {
            json.array();
            for (String appId : appIds) {
                json.value(appId);
            }
            json.endArray();
        } catch (JSONException e) {
            throw new ServletException(e);
        }
        appendJsonpCallbackEnd(jsonpCallback, writer);
    }
}

17 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds a value to a writer if value is not <code>null</code>.
 *
 * @param writer
 *            writer to add object to.
 * @param field
 *            field name to set.
 * @param value
 *            field value.
 * @throws JSONException
 *             if io error occurs.
 */
public static void addIfNotNull(JSONWriter writer, String field, String value) throws JSONException {
    if (value == null)
        return;
    writer.key(field);
    writer.value(value);
}

17 View Complete Implementation : DataSourceAttribute.java
Copyright BSD 2-Clause "Simplified" License
Author : mapfish
@Override
public void printClientConfig(final JSONWriter json, final Template template) throws JSONException {
    try {
        json.key(ReflectiveAttribute.JSON_NAME).value(this.configName);
        json.key(ReflectiveAttribute.JSON_ATTRIBUTE_TYPE).value(DataSourceAttributeValue.clreplaced.getSimpleName());
        json.key(ReflectiveAttribute.JSON_CLIENT_PARAMS);
        json.object();
        json.key("attributes");
        json.array();
        for (Map.Entry<String, Attribute> entry : this.attributes.entrySet()) {
            Attribute attribute = entry.getValue();
            if (attribute.getClreplaced().getAnnotation(InternalAttribute.clreplaced) == null) {
                json.object();
                attribute.printClientConfig(json, template);
                json.endObject();
            }
        }
        json.endArray();
        json.endObject();
    } catch (Throwable e) {
        // Note: If this test fails and you just added a new attribute, make
        // sure to set defaults in AbstractMapfishSpringTest.configureAttributeForTesting
        throw new Error("Error printing the clientConfig of: " + DataSourceAttribute.clreplaced.getName(), e);
    }
}

17 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds a value to a writer if value is not <code>null</code>.
 *
 * @param writer
 *            writer to add object to.
 * @param field
 *            field name to set.
 * @param value
 *            field value.
 * @throws JSONException
 *             if io error occurs.
 */
public static void addIfNotNull(JSONWriter writer, String field, Boolean value) throws JSONException {
    if (value == null)
        return;
    writer.key(field);
    writer.value(value);
}

17 View Complete Implementation : Template.java
Copyright BSD 2-Clause "Simplified" License
Author : mapfish
/**
 * Print out the template information that the client needs for performing a request.
 *
 * @param json the writer to write the information to.
 */
public final void printClientConfig(final JSONWriter json) throws JSONException {
    json.key("attributes");
    json.array();
    for (Map.Entry<String, Attribute> entry : this.attributes.entrySet()) {
        Attribute attribute = entry.getValue();
        if (attribute.getClreplaced().getAnnotation(InternalAttribute.clreplaced) == null) {
            json.object();
            attribute.printClientConfig(json, this);
            json.endObject();
        }
    }
    json.endArray();
}

17 View Complete Implementation : SemanticType.java
Copyright Apache License 2.0
Author : usc-isi-i2
public void write(JSONWriter writer) throws JSONException {
    writer.object();
    writer.key("HNodeId").value(hNodeId);
    writer.key("Type").value(type);
    writer.key("Origin").value(origin.name());
    writer.key("ConfidenceLevel").value(confidenceLevel.name());
    writer.endObject();
}

17 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds a value to a writer if value is not <code>null</code>.
 *
 * @param writer
 *            writer to add object to.
 * @param field
 *            field name to set.
 * @param value
 *            field value.
 * @throws JSONException
 *             if io error occurs.
 */
public static void addIfNotNull(JSONWriter writer, String field, Float value) throws JSONException {
    if (value == null)
        return;
    writer.key(field);
    writer.value(value);
}

17 View Complete Implementation : SynonymSemanticTypes.java
Copyright Apache License 2.0
Author : usc-isi-i2
public void write(JSONWriter writer) throws JSONException {
    writer.array();
    for (SemanticType type : synonyms) {
        type.write(writer);
    }
    writer.endArray();
}

17 View Complete Implementation : JsonOutput.java
Copyright Apache License 2.0
Author : taskadapter
/**
 * Adds a value to a writer if value is not <code>null</code>.
 *
 * @param writer
 *            writer to add object to.
 * @param field
 *            field name to set.
 * @param value
 *            field value.
 * @throws JSONException
 *             if io error occurs.
 */
public static void addIfNotNull(JSONWriter writer, String field, Integer value) throws JSONException {
    if (value == null)
        return;
    writer.key(field);
    writer.value(value);
}

17 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeMembership(JSONWriter writer, Membership membership) throws JSONException {
    final PropertyStorage storage = membership.getStorage();
    addIfSet(writer, "user_id", storage, Membership.USER_ID);
    addIfSet(writer, "group_id", storage, Membership.GROUP_ID);
    if (membership.getRoles() != null) {
        writer.key("role_ids");
        writer.array();
        for (Role role : membership.getRoles()) {
            writer.value(role.getId().longValue());
        }
        writer.endArray();
    }
}

16 View Complete Implementation : RedmineJSONBuilder.java
Copyright Apache License 2.0
Author : taskadapter
public static void writeUser(final JSONWriter writer, User user) throws JSONException {
    PropertyStorage storage = user.getStorage();
    addIfSet(writer, "id", storage, User.ID);
    addIfSet(writer, "login", storage, User.LOGIN);
    addIfSet(writer, "preplacedword", storage, User.PreplacedWORD);
    addIfSet(writer, "firstname", storage, User.FIRST_NAME);
    addIfSet(writer, "lastname", storage, User.LAST_NAME);
    // TODO I don't think this "name" is required... check this.
    // addIfSet(writer, "name", storage, User.FULL_NAME);
    addIfSet(writer, "mail", storage, User.MAIL);
    addIfSet(writer, "auth_source_id", storage, User.AUTH_SOURCE_ID);
    addIfSet(writer, "status", storage, User.STATUS);
    addIfSetFullDate(writer, "created_on", storage, User.CREATED_ON);
    addIfSetFullDate(writer, "last_login_on", storage, User.LAST_LOGIN_ON);
    addIfSet(writer, "mail_notification", storage, User.MAIL_NOTIFICATION);
    addIfSet(writer, "must_change_preplacedwd", storage, User.MUST_CHANGE_PreplacedWD);
    addIfSet(writer, "generate_preplacedword", storage, User.GENERATE_PreplacedWORD);
    writeCustomFields(writer, user.getCustomFields());
}