コード例 #1
0
 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();
     }
   }
 }
コード例 #2
0
 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();
     }
   }
 }
コード例 #3
0
 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;
 }