當前位置: 首頁>>代碼示例>>Java>>正文


Java PathNotFoundException類代碼示例

本文整理匯總了Java中com.jayway.jsonpath.PathNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java PathNotFoundException類的具體用法?Java PathNotFoundException怎麽用?Java PathNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PathNotFoundException類屬於com.jayway.jsonpath包,在下文中一共展示了PathNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: element

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
public SpinJsonNode element() {
  try {
    Object result = query.read(spinJsonNode.toString(), dataFormat.getJsonPathConfiguration());
    JsonNode node;
    if (result != null) {
      node = dataFormat.createJsonNode(result);
    } else {
      node = dataFormat.createNullJsonNode();
    }
    return dataFormat.createWrapperInstance(node);
  } catch(PathNotFoundException pex) {
    throw LOG.unableToEvaluateJsonPathExpressionOnNode(spinJsonNode, pex);
  } catch (ClassCastException cex) {
    throw LOG.unableToCastJsonPathResultTo(SpinJsonNode.class, cex);
  } catch(InvalidPathException iex) {
    throw LOG.invalidJsonPath(SpinJsonNode.class, iex);
  }
}
 
開發者ID:camunda,項目名稱:camunda-spin,代碼行數:19,代碼來源:JacksonJsonPathQuery.java

示例2: assertPaths

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
private void assertPaths(JsonNode node, boolean shouldExist, String... paths) {
    Object document = Configuration.defaultConfiguration().jsonProvider().parse(node.toString());
    for (String path : paths) {
        try {
            Object object = JsonPath.read(document, path);
            if (isIndefinite(path)) {
                Collection c = (Collection) object;
                assertThat(c.isEmpty()).isNotEqualTo(shouldExist);
            } else if (!shouldExist) {
                Assert.fail("Expected path not to be found: " + path);
            }
        } catch (PathNotFoundException e) {
            if (shouldExist) {
                Assert.fail("Path not found: " + path);
            }
        }
    }
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:19,代碼來源:IntegrationTestCase.java

示例3: checkArrayModel

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
/**
 * Check if model is non-null and array.
 * @param currentPath
 * @param model
 * @param ctx
 * @return false if current evaluation call must be skipped, true otherwise
 * @throws PathNotFoundException if model is null and evaluation must be interrupted
 * @throws InvalidPathException if model is not an array and evaluation must be interrupted
 */
protected boolean checkArrayModel(String currentPath, Object model, EvaluationContextImpl ctx) {
    if (model == null){
        if (! isUpstreamDefinite()) {
            return false;
        } else {
            throw new PathNotFoundException("The path " + currentPath + " is null");
        }
    }
    if (!ctx.jsonProvider().isArray(model)) {
        if (! isUpstreamDefinite()) {
            return false;
        } else {
            throw new PathNotFoundException(format("Filter: %s can only be applied to arrays. Current context is: %s", toString(), model));
        }
    }
    return true;
}
 
開發者ID:osswangxining,項目名稱:another-rule-based-analytics-on-spark,代碼行數:27,代碼來源:ArrayPathToken.java

示例4: getValue

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T> T getValue(boolean unwrap) {
    if (path.isDefinite()) {
        if(resultIndex == 0){
            throw new PathNotFoundException("No results for path: " + path.toString());
        }
        int len = jsonProvider().length(valueResult);
        Object value = (len > 0) ? jsonProvider().getArrayIndex(valueResult, len-1) : null;
        if (value != null && unwrap){
          value = jsonProvider().unwrap(value);
        }
        return (T) value;
    }
    return (T)valueResult;
}
 
開發者ID:osswangxining,項目名稱:another-rule-based-analytics-on-spark,代碼行數:17,代碼來源:EvaluationContextImpl.java

示例5: evaluate

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
@Override
public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) {
    if (ctx.jsonProvider().isMap(model)) {
        for (String property : ctx.jsonProvider().getPropertyKeys(model)) {
            handleObjectProperty(currentPath, model, ctx, asList(property));
        }
    } else if (ctx.jsonProvider().isArray(model)) {
        for (int idx = 0; idx < ctx.jsonProvider().length(model); idx++) {
            try {
                handleArrayIndex(idx, currentPath, model, ctx);
            } catch (PathNotFoundException p){
                if(ctx.options().contains(Option.REQUIRE_PROPERTIES)){
                    throw p;
                }
            }
        }
    }
}
 
開發者ID:osswangxining,項目名稱:another-rule-based-analytics-on-spark,代碼行數:19,代碼來源:WildcardPathToken.java

示例6: completeBasedOnJsonpathMatches

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
private void completeBasedOnJsonpathMatches(String kind, List<String> words,
        List<Candidate> candidates) {
    if (ctx != null) {
        try {
            List<String> names = ctx.read(String.format("$.%s[*].name", kind));
            Optional<String> name = names.stream().filter(words::contains).map(String::toString)
                    .findFirst();
            if (name.isPresent()) {
                List<String> parameterNames = ctx.read(String
                        .format("$.%s[?(@.name=='%s')].parameters[*].name", kind, name.get()));
                completeParameters(kind, words, candidates, parameterNames);
                parameterNames = ctx.read(String
                        .format("$.%s[?(@.name=='%s')].mapped_parameters[*].local_key", kind, name.get()));
                completeParameters(kind, words, candidates, parameterNames);
            }
            else {
                names.forEach(n -> candidates.add(new Candidate(n)));
            }
        }
        catch (PathNotFoundException e) {
            // This is ok as it means we don't have the matching operation in the cache
        }
    }
}
 
開發者ID:atomist-attic,項目名稱:rug-cli,代碼行數:25,代碼來源:OperationCompleter.java

示例7: addFieldToSolrString

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
private String addFieldToSolrString(JsonPath jp, Object sourceProfile) {
    String fields = "";
    try {    
        Object field = jp.read(sourceProfile);
        if (!(field instanceof List)) {
            if (!(field instanceof String)) {
                field = field.toString();
            }
            fields += (String) field + " ";
        } else {
            for (Object field1 : (List)field) {
                if (!(field1 instanceof String)) {
                field1 = field1.toString();
            }
            fields += (String)field1 + " ";
            }
        }
    } catch (PathNotFoundException pnfe) {
        logger.debug("Path not found in profile " + pnfe.getMessage());
    }
    return fields;
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:23,代碼來源:SolrSimilarityServiceImpl.java

示例8: poll

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
/**
 * Polls the base URL for the DDI API interface.
 */
@Override
public void poll() {
    if (!removed) {
        final String basePollJson = controllerResource.get(getTenant(), getId());
        try {
            final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href");
            final long actionId = Long.parseLong(href.substring(href.lastIndexOf('/') + 1, href.indexOf('?')));
            if (currentActionId == null) {
                final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
                final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
                currentActionId = actionId;
                startDdiUpdate(actionId, swVersion);
            }
        } catch (final PathNotFoundException e) {
            // href might not be in the json response, so ignore
            // exception here.
            LOGGER.trace("Response does not contain a deploymentbase href link, ignoring.", e);
        }

    }
}
 
開發者ID:eclipse,項目名稱:hawkbit-examples,代碼行數:25,代碼來源:DDISimulatedDevice.java

示例9: hello

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
@Test
public void hello() throws URISyntaxException, IOException {
	String jsonString = FileUtils.readFirstLine("general/test.json");

	Object jsonDocument = Configuration.defaultConfiguration().jsonProvider().parse(jsonString);
	for (JsonBranch collectionBranch : schema.getCollectionPaths()) {
		Object rawCollection = null;
		try {
			rawCollection = JsonPath.read(jsonDocument, collectionBranch.getJsonPath());
		} catch (PathNotFoundException e) {}
		if (rawCollection != null) {
			if (rawCollection instanceof JSONArray) {
				JSONArray collection = (JSONArray)rawCollection;
				collection.forEach(
					node -> {
						processNode(node, collectionBranch.getChildren());
					}
				);
			} else {
				processNode(rawCollection, collectionBranch.getChildren());
			}
		}
	}
}
 
開發者ID:pkiraly,項目名稱:metadata-qa-api,代碼行數:25,代碼來源:NodeEnabledCalculatorTest.java

示例10: readRegenerateFlagFrom

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
private boolean readRegenerateFlagFrom(String requestString) {
  boolean isRegenerateRequest;
  try {
    isRegenerateRequest = JsonPath.read(requestString, "$.regenerate");
  } catch (PathNotFoundException e) {
    // could have just returned null, that would have been pretty useful
    isRegenerateRequest = false;
  }
  return isRegenerateRequest;
}
 
開發者ID:cloudfoundry-incubator,項目名稱:credhub,代碼行數:11,代碼來源:LegacyGenerationHandler.java

示例11: read

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
/**
 * Reads the given 'responseElements' and extracts information based on given 'pattern'.<br/>
 * If 'responseElements' is null or empty you can handle the {@link IllegalArgumentException} raised or got an empty
 * list.
 */
public static List<String> read(final String responseElements, final String pattern,
                                final boolean emptyListOnNullOrEmptyResponse) {
    if (isNullOrEmpty(responseElements) && emptyListOnNullOrEmptyResponse) {
        return emptyList();
    }

    try {
        return JsonPath.read(responseElements, pattern);
    } catch (final PathNotFoundException e) {
        if (emptyListOnNullOrEmptyResponse) {
            return emptyList();
        } else {
            throw e;
        }
    }
}
 
開發者ID:zalando-stups,項目名稱:fullstop,代碼行數:22,代碼來源:CloudTrailEventSupport.java

示例12: getRequestField

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
private String getRequestField(DataAccessRequest request, String fieldPath) {
  String rawContent = request.getContent();
  if(!Strings.isNullOrEmpty(fieldPath) && !Strings.isNullOrEmpty(rawContent)) {
    Object content = Configuration.defaultConfiguration().jsonProvider().parse(rawContent);
    List<Object> values = null;
    try {
      values = JsonPath.using(conf).parse(content).read(fieldPath);
    } catch(PathNotFoundException ex) {
      //ignore
    } catch(InvalidPathException e) {
      log.warn("Invalid jsonpath {}", fieldPath);
    }

    if(values != null) {
      return values.get(0).toString();
    }
  }
  return null;
}
 
開發者ID:obiba,項目名稱:mica2,代碼行數:20,代碼來源:DataAccessRequestUtilService.java

示例13: isSafe

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
@Override
public final boolean isSafe(final String url) {
  boolean safe = true;
  try {
    final MultiValueMap<String, String> formParameters = this.config.getParameters();
    formParameters.add(PARAMETER_URL, url);
    final ResponseEntity<String> response = this.client.postForEntity(this.config.getApiUrl(), formParameters, String.class);
    if (response.getStatusCode() == HttpStatus.OK) {
      final boolean phish = JsonPath.parse(response.getBody()).read(IN_DATABASE_PARSE_EXPRESSION);
      if (phish) {
        LOGGER.warn("Possible malicious link posted: {}", url);
        LOGGER.debug("PhishTank response: {}", response);
        safe = false;
      }
    } else {
      LOGGER.warn("Request for PhishTank API failed with status: {} - : {}", response.getStatusCode(), response);
    }
  } catch (final RestClientException | PathNotFoundException exception) {
    LOGGER.warn("Something went wrong while processing PhishTank API: {}", exception);
  }
  return safe;
}
 
開發者ID:drissamri,項目名稱:linkshortener,代碼行數:23,代碼來源:PhishTankUrlVerifier.java

示例14: testNoJoinIdsAtPath

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
@Test(expected=PathNotFoundException.class)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testNoJoinIdsAtPath() throws IOException {
  NamedList args = new NamedList();
  args.add(SimpleXJoinResultsFactory.INIT_PARAM_TYPE, SimpleXJoinResultsFactory.Type.JSON.toString());
  args.add(SimpleXJoinResultsFactory.INIT_PARAM_ROOT_URL, getClass().getResource("results.json").toString());
  
  NamedList globalPaths = new NamedList();
  args.add(SimpleXJoinResultsFactory.INIT_PARAM_GLOBAL_FIELD_PATHS, globalPaths);
  globalPaths.add("total", "$.count");
  
  args.add(SimpleXJoinResultsFactory.INIT_PARAM_JOIN_ID_PATH, "$.no.ids.at.this.path");
  
  SimpleXJoinResultsFactory factory = new SimpleXJoinResultsFactory();
  factory.init(args);
  
  SolrParams params = new ModifiableSolrParams();
  XJoinResults<String> results = factory.getResults(params);
  
  assertEquals(0, IteratorUtils.toArray(results.getJoinIds().iterator()).length);
}
 
開發者ID:flaxsearch,項目名稱:BioSolr,代碼行數:22,代碼來源:TestSimpleXJoinResultsFactory.java

示例15: mapJson

import com.jayway.jsonpath.PathNotFoundException; //導入依賴的package包/類
public void mapJson(FieldMapContext context, Object jsonObject, IndexDocument target)
		throws SearchLibException, IOException, ParseException, SyntaxError, URISyntaxException,
		ClassNotFoundException, InterruptedException, InstantiationException, IllegalAccessException {
	for (GenericLink<SourceField, CommonFieldTarget> link : getList()) {
		String jsonPath = link.getSource().getUniqueName();
		try {
			Object jsonContent = JsonPath.read(jsonObject, jsonPath);
			if (jsonContent == null)
				continue;
			if (jsonContent instanceof JSONArray) {
				JSONArray jsonArray = (JSONArray) jsonContent;
				for (Object content : jsonArray) {
					if (content != null)
						mapFieldTarget(context, link.getTarget(), false, content.toString(), target, null);
				}
			} else
				mapFieldTarget(context, link.getTarget(), false, jsonContent.toString(), target, null);
		} catch (PathNotFoundException | IllegalArgumentException e) {
			Logging.warn(e);
		}
	}
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:23,代碼來源:RestFieldMap.java


注:本文中的com.jayway.jsonpath.PathNotFoundException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。