public static boolean isValueExists(IStructuredDocument document, IJSONPath path) { IJSONModel model = null; try { model = (IJSONModel) StructuredModelManager.getModelManager().getModelForRead(document); IJSONPair pair = findByPath(model.getDocument(), path.getSegments()); return pair != null; } finally { if (model != null) { model.releaseFromRead(); } } }
public static void removePath(IStructuredDocument document, IJSONPath path) { IJSONModel model = null; try { model = (IJSONModel) StructuredModelManager.getModelManager().getModelForRead(document); IJSONPair pair = findByPath(model.getDocument(), path.getSegments()); if (pair != null) { document.replaceText( document, pair.getStartOffset(), pair.getEndOffset() - pair.getStartOffset(), ""); } } finally { if (model != null) { model.releaseFromRead(); } } }
public static Object getValue(IStructuredDocument document, IJSONPath path) { IJSONModel model = null; try { model = (IJSONModel) StructuredModelManager.getModelManager().getModelForRead(document); IJSONPair pair = findByPath(model.getDocument(), path.getSegments()); if (pair != null) { IJSONValue value = pair.getValue(); return getValue(value); } } finally { if (model != null) { model.releaseFromRead(); } } return null; }