use of org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter in project org.openntf.domino by OpenNTF.
the class JsonGraphWriter method outLiteral.
@Override
protected void outLiteral(Object paramObject, final boolean paramBoolean) throws IOException, JsonException {
// paramObject.getClass().getName()));
if (paramObject != null) {
Class<?> objClass = paramObject.getClass();
IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
if (adapter != null) {
paramObject = adapter.toJson(paramObject);
}
}
if (this.getFactory().isNull(paramObject)) {
outNull();
// } else if (paramObject instanceof Term) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
// } else if (paramObject instanceof Value) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
// } else if (paramObject instanceof RichTextReference) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
} else if (paramObject instanceof VertexFrame) {
JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
outObject(adapter);
} else if (paramObject instanceof EdgeFrame) {
JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
outObject(adapter);
} else if (paramObject instanceof Class<?>) {
String className = ((Class) paramObject).getName();
outStringLiteral(className);
} else if (paramObject instanceof RichTextItem) {
outRichTextItem((RichTextItem) paramObject);
} else if (paramObject instanceof Enum) {
String className = ((Enum) paramObject).getClass().getName();
String enumName = ((Enum) paramObject).name();
outStringLiteral(className + " " + enumName);
} else if (paramObject instanceof CharSequence) {
outStringLiteral(paramObject.toString());
} else if (paramObject instanceof Set) {
// System.out.println("TEMP DEBUG Got a set!");
outArrayLiteral(((Set) paramObject).toArray());
} else if (this.getFactory().isString(paramObject)) {
outStringLiteral(this.getFactory().getString(paramObject));
} else if (this.getFactory().isNumber(paramObject)) {
outNumberLiteral(this.getFactory().getNumber(paramObject));
} else if (this.getFactory().isBoolean(paramObject)) {
outBooleanLiteral(this.getFactory().getBoolean(paramObject));
} else if (this.getFactory().isObject(paramObject)) {
outObject(paramObject, paramBoolean);
} else if (this.getFactory().isArray(paramObject)) {
outArrayLiteral(paramObject, paramBoolean);
} else if (paramObject instanceof JsonReference) {
outReference((JsonReference) paramObject);
} else if (paramObject instanceof DateTime) {
DateTime dt = (DateTime) paramObject;
outDateLiteral_(dt.toJavaDate());
} else if (paramObject instanceof DateRange) {
DateRange dt = (DateRange) paramObject;
outDateRangeLiteral(dt);
} else if (paramObject instanceof NoteCoordinate) {
outNoteCoordinate((NoteCoordinate) paramObject);
} else if (paramObject instanceof Date) {
outDateLiteral_((Date) paramObject);
} else {
outStringLiteral("JsonGenerator cannot process unknown type of " + ((paramObject != null) ? paramObject.getClass().getName() : "<null>"));
}
}
use of org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter in project org.openntf.domino by OpenNTF.
the class JsonGraphWriter method outObject.
@Override
public void outObject(Object paramObject) throws IOException, JsonException {
// + (paramObject == null ? "NULL" : paramObject.getClass().getName()));
try {
if (paramObject != null) {
Class<?> objClass = paramObject.getClass();
IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
if (adapter != null) {
paramObject = adapter.toJson(paramObject);
}
}
if (paramObject == null) {
super.outNull();
// } else if (paramObject instanceof Term) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
// } else if (paramObject instanceof Value) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
// } else if (paramObject instanceof RichTextReference) {
// JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
// isCollectionRoute_);
// super.outObject(adapter);
} else if (paramObject instanceof EdgeFrame) {
JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
super.outObject(adapter);
} else if (paramObject instanceof VertexFrame) {
JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
super.outObject(adapter);
} else if (paramObject instanceof Class<?>) {
String className = ((Class<?>) paramObject).getName();
super.outStringLiteral(className);
} else if (paramObject instanceof RichTextItem) {
outRichTextItem((RichTextItem) paramObject);
} else if (paramObject instanceof Enum) {
String className = ((Enum<?>) paramObject).getClass().getName();
String enumName = ((Enum<?>) paramObject).name();
} else if (paramObject instanceof NoteCoordinate) {
String nc = ((NoteCoordinate) paramObject).toString();
super.outStringLiteral(nc);
} else if (paramObject instanceof org.openntf.domino.impl.View.DominoColumnInfo) {
String itemName = ((org.openntf.domino.impl.View.DominoColumnInfo) paramObject).getItemName();
super.outStringLiteral(itemName);
} else if (paramObject instanceof Set) {
// System.out.println("TEMP DEBUG outObject received a Set");
outArrayLiteral(((Set) paramObject).toArray());
} else if (paramObject instanceof DateTime) {
outDateLiteral((DateTime) paramObject);
} else if (paramObject instanceof DateRange) {
outDateRangeLiteral((DateRange) paramObject);
} else if (paramObject instanceof NoteCoordinate) {
outNoteCoordinate((NoteCoordinate) paramObject);
} else if (paramObject instanceof Throwable) {
outException((Throwable) paramObject);
} else {
// Class<?> clazz = paramObject.getClass();
// String name = clazz.getName();
super.outObject(paramObject);
}
} catch (UserAccessException uae) {
throw uae;
} catch (RuntimeException re) {
throw re;
} catch (Throwable t) {
t.printStackTrace();
}
}
Aggregations