public void writeArrayEnd () { try { writer.pop(); } catch (IOException ex) { throw new SerializationException(ex); } }
/** Writes the specified field to the current JSON object. * @param elementType May be null if the type is unknown. */ public void writeField (Object object, String fieldName, String jsonName, Class elementType) { Class type = object.getClass(); ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new SerializationException("Field not found: " + fieldName + " (" + type.getName() + ")"); Field field = metadata.field; if (elementType == null) elementType = metadata.elementType; try { if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(jsonName); writeValue(field.get(object), field.getType(), elementType); } catch (ReflectionException ex) { throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } }
/** Returns true if any of the exceptions that caused this exception are of the specified type. */ public boolean causedBy (Class type) { return causedBy(this, type); }
public void loadChapter(String selChapter) throws IOException { undoStack.clear(); setSelectedScene(null); try { chapter.load(selChapter); firePropertyChange(NOTIFY_CHAPTER_LOADED); getEditorConfig().setProperty("project.selectedChapter", selChapter); } catch (SerializationException ex) { // check for not compiled custom actions if (ex.getCause() != null && ex.getCause() instanceof ClassNotFoundException) { EditorLogger.msg("Custom action class not found. Trying to compile..."); if (RunProccess.runGradle(getProjectDir(), "desktop:compileJava")) { ((FolderClassLoader)ActionFactory.getActionClassLoader()).reload(); chapter.load(selChapter); } else { throw new IOException("Failed to run Gradle."); } } else { throw ex; } } i18n.load(selChapter); }
public void writeArrayEnd () { try { writer.pop(); } catch (IOException ex) { throw new SerializationException(ex); } }
/** Writes the specified field to the current JSON object. * @param elementType May be null if the type is unknown. */ public void writeField (Object object, String fieldName, String jsonName, Class elementType) { Class type = object.getClass(); ObjectMap<String, FieldMetadata> fields = getFields(type); FieldMetadata metadata = fields.get(fieldName); if (metadata == null) throw new SerializationException("Field not found: " + fieldName + " (" + type.getName() + ")"); Field field = metadata.field; if (elementType == null) elementType = metadata.elementType; try { if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")"); writer.name(jsonName); writeValue(field.get(object), field.getType(), elementType); } catch (ReflectionException ex) { throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } catch (Exception runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(field + " (" + type.getName() + ")"); throw ex; } }
/** Returns true if any of the exceptions that caused this exception are of the specified type. */ public boolean causedBy (Class type) { return causedBy(this, type); }
public void writeObjectStart () { try { writer.object(); } catch (IOException ex) { throw new SerializationException(ex); } }
continue; } else { SerializationException ex = new SerializationException( "Field not found: " + child.name + " (" + type.getName() + ")"); ex.addTrace(child.trace()); throw ex; field.set(object, readValue(field.getType(), metadata.elementType, child)); } catch (ReflectionException ex) { throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field.getName() + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(child.trace()); ex.addTrace(field.getName() + " (" + type.getName() + ")"); throw ex;
private boolean causedBy (Throwable ex, Class type) { Throwable cause = ex.getCause(); if (cause == null || cause == ex) return false; if (type.isAssignableFrom(cause.getClass())) return true; return causedBy(cause, type); }
public void writeObjectEnd () { try { writer.pop(); } catch (IOException ex) { throw new SerializationException(ex); } }
/** @param object May be null if the field is static. * @param elementType May be null if the type is unknown. */ public void readField (Object object, Field field, String jsonName, Class elementType, JsonValue jsonMap) { JsonValue jsonValue = jsonMap.get(jsonName); if (jsonValue == null) return; try { field.set(object, readValue(field.getType(), elementType, jsonValue)); } catch (ReflectionException ex) { throw new SerializationException( "Error accessing field: " + field.getName() + " (" + field.getDeclaringClass().getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field.getName() + " (" + field.getDeclaringClass().getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(jsonValue.trace()); ex.addTrace(field.getName() + " (" + field.getDeclaringClass().getName() + ")"); throw ex; } }
private boolean causedBy (Throwable ex, Class type) { Throwable cause = ex.getCause(); if (cause == null || cause == ex) return false; if (type.isAssignableFrom(cause.getClass())) return true; return causedBy(cause, type); }
public void writeObjectStart () { try { writer.object(); } catch (IOException ex) { throw new SerializationException(ex); } }
continue; } else { SerializationException ex = new SerializationException( "Field not found: " + child.name + " (" + type.getName() + ")"); ex.addTrace(child.trace()); throw ex; field.set(object, readValue(field.getType(), metadata.elementType, child)); } catch (ReflectionException ex) { throw new SerializationException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field.getName() + " (" + type.getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(child.trace()); ex.addTrace(field.getName() + " (" + type.getName() + ")"); throw ex;
/** Returns true if any of the exceptions that caused this exception are of the specified type. */ public boolean causedBy (Class type) { return causedBy(this, type); }
public void writeObjectEnd () { try { writer.pop(); } catch (IOException ex) { throw new SerializationException(ex); } }
/** @param object May be null if the field is static. * @param elementType May be null if the type is unknown. */ public void readField (Object object, Field field, String jsonName, Class elementType, JsonValue jsonMap) { JsonValue jsonValue = jsonMap.get(jsonName); if (jsonValue == null) return; try { field.set(object, readValue(field.getType(), elementType, jsonValue)); } catch (ReflectionException ex) { throw new SerializationException( "Error accessing field: " + field.getName() + " (" + field.getDeclaringClass().getName() + ")", ex); } catch (SerializationException ex) { ex.addTrace(field.getName() + " (" + field.getDeclaringClass().getName() + ")"); throw ex; } catch (RuntimeException runtimeEx) { SerializationException ex = new SerializationException(runtimeEx); ex.addTrace(jsonValue.trace()); ex.addTrace(field.getName() + " (" + field.getDeclaringClass().getName() + ")"); throw ex; } }
private boolean causedBy (Throwable ex, Class type) { Throwable cause = ex.getCause(); if (cause == null || cause == ex) return false; if (type.isAssignableFrom(cause.getClass())) return true; return causedBy(cause, type); }