List of usage examples for com.google.gson JsonArray JsonArray
public JsonArray()
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonParameterAnnotations(MethodBinding method) { AnnotationBinding[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (AnnotationBinding[] parameterAnnotation : parameterAnnotations) { array.add(toJsonAnnotations(parameterAnnotation)); }//from w w w .j a v a2 s. c o m return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonExceptionTypeNames(ReferenceBinding[] thrownExceptions) { if (thrownExceptions == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding exception : thrownExceptions) { array.add(new JsonPrimitive(new String(exception.constantPoolName()))); }// ww w . j ava 2 s .c o m return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonDefaultValue(Object defaultValue) { if (defaultValue == null) return JsonNull.INSTANCE; JsonObject object = new JsonObject(); if (defaultValue instanceof Constant) { object.add("constant", BinaryTypeConvector.toJsonConstant((Constant) defaultValue)); } else if (defaultValue instanceof TypeBinding) { object.addProperty("class", new String(((TypeBinding) defaultValue).constantPoolName())); } else if (defaultValue instanceof AnnotationBinding) { object.add("annotation", toJsonAnnotation((AnnotationBinding) defaultValue)); } else if (defaultValue instanceof FieldBinding) { FieldBinding signature = (FieldBinding) defaultValue; JsonObject enumSignature = new JsonObject(); enumSignature.addProperty("typeName", new String(signature.type.signature())); enumSignature.addProperty("constantName", new String(signature.name)); object.add("enum", enumSignature); } else if (defaultValue instanceof Object[]) { JsonArray array = new JsonArray(); for (Object o : (Object[]) defaultValue) { array.add(toJsonDefaultValue(o)); }//from w ww . j a v a 2s. co m object.add("array", array); } return object; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonParametersName(AbstractMethodDeclaration parameters) { if (parameters == null || parameters.arguments == null || parameters.arguments.length == 0) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (Argument parameter : parameters.arguments) { array.add(new JsonPrimitive(new String(parameter.binding.name))); }/*w w w . j a v a 2s .c om*/ return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonMemberTypes(ReferenceBinding[] memberTypes) { if (memberTypes == null || memberTypes.length == 0) return null; JsonArray array = new JsonArray(); for (ReferenceBinding type : memberTypes) { array.add(toJsonMemberType(type)); }//w ww . ja v a 2 s .com return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonInterfaces(ReferenceBinding[] interfaces) { if (interfaces == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding anInterface : interfaces) { array.add(new JsonPrimitive(new String(anInterface.constantPoolName()))); }/* w w w.j ava2 s . c o m*/ return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonFields(FieldBinding[] fields) { if (fields == null || fields.length == 0) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (FieldBinding field : fields) { array.add(toJsonField(field));//from w ww.j ava 2s . co m } return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonAnnotations(AnnotationBinding[] annotations) { if (annotations == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (AnnotationBinding annotation : annotations) { array.add(toJsonAnnotation(annotation)); }/*from w w w. ja va 2s . c o m*/ return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonElementValuePairs(ElementValuePair[] elementValuePairs) { if (elementValuePairs == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ElementValuePair pair : elementValuePairs) { array.add(toJsonElementValuePair(pair)); }//from w ww .jav a2s .c om return array; }
From source file:com.cognifide.aet.vs.metadata.CollectionSerializer.java
License:Apache License
@Override public JsonElement serialize(Collection<?> src, Type typeOfSrc, JsonSerializationContext context) { if (src == null || src.isEmpty()) { return null; }/*w w w . java2s .c o m*/ JsonArray array = new JsonArray(); for (Object child : src) { JsonElement element = context.serialize(child); array.add(element); } return array; }