Tabnine Logo
ObjectNode.has
Code IndexAdd Tabnine to your IDE (free)

How to use
has
method
in
org.codehaus.jackson.node.ObjectNode

Best Java code snippets using org.codehaus.jackson.node.ObjectNode.has (Showing top 20 results out of 315)

origin: kaaproject/kaa

if (!object.has(TYPE) || !object.get(TYPE).isTextual()
  || !object.get(TYPE).getTextValue().equals("record")) {
 throw new IllegalArgumentException("The data provided is not a record!");
if (!object.has(NAMESPACE) || !object.get(NAMESPACE).isTextual()) {
 throw new IllegalArgumentException("No namespace specified!");
} else if (!object.has(NAME) || !object.get(NAME).isTextual()) {
 throw new IllegalArgumentException("No name specified!");
} else {
schema.setMetaInfo(metaInfo);
if (!object.has(VERSION) || !object.get(VERSION).isInt()) {
 object.put(VERSION, 1);
if (!object.has(DEPENDENCIES)) {
 schema.setDependencySet(dependencies);
} else if (!object.get(DEPENDENCIES).isArray()) {
origin: algesten/jsondiff

@Override
public boolean has(String key) {
  return wrapped.has(key);
}
origin: com.github.foodev/jsondiff

@Override
public boolean has(String key) {
  return wrapped.has(key);
}
origin: eBay/YiDB

@Override
public boolean hasField(String fieldName) {
  return getNode().has(fieldName);
}
 
origin: org.jboss.seam.social/seam-social-facebook

private String determinePostType(ObjectNode node) {
  if (node.has("type")) {
    try {
      String type = node.get("type").getTextValue();
      PostType.valueOf(type.toUpperCase());
      return type;
    } catch (IllegalArgumentException e) {
      return "post";
    }
  }
  return "post";
}
origin: eBay/YiDB

@Override
public boolean hasFieldProperty(String fieldName, String propertyName) {
  FieldProperty property = FieldProperty.fromQueryName(propertyName);
  CheckConditions.checkNotNull(property, "Can not find field property %s!", propertyName);
  String propertyFullName = fieldName + PROPERTY_CONNECTOR + propertyName;
  return getNode().has(propertyFullName);
}
origin: apache/stanbol

@Override
public PosTag parse(ObjectNode jValue, AnalysedText at) {
  PosTagInfo tagInfo = new PosTagInfo();
  JsonNode tag = jValue.path("tag");
  if(!tag.isTextual()){
    throw new IllegalStateException("Unable to parse PosTag. The value of the "
        +"'tag' field MUST have a textual value (json: "+jValue+")");
  }
  tagInfo.tag = tag.getTextValue();
  if(jValue.has("lc")){
    tagInfo.categories = JsonUtils.parseEnum(jValue, "lc",LexicalCategory.class);
  } else {
    tagInfo.categories = EnumSet.noneOf(LexicalCategory.class);
  }
  if(jValue.has("pos")){
    tagInfo.pos = JsonUtils.parseEnum(jValue, "pos", Pos.class);
  } else {
    tagInfo.pos = EnumSet.noneOf(Pos.class);
  }
  PosTag posTag = posTagCache.get(tagInfo);
  if(posTag == null){
    posTag = new PosTag(tagInfo.tag,tagInfo.categories,tagInfo.pos);
    posTagCache.put(tagInfo, posTag);
  }
  return posTag;
}
origin: org.apache.stanbol/org.apache.stanbol.enhancer.nlp.json

@Override
public PosTag parse(ObjectNode jValue, AnalysedText at) {
  PosTagInfo tagInfo = new PosTagInfo();
  JsonNode tag = jValue.path("tag");
  if(!tag.isTextual()){
    throw new IllegalStateException("Unable to parse PosTag. The value of the "
        +"'tag' field MUST have a textual value (json: "+jValue+")");
  }
  tagInfo.tag = tag.getTextValue();
  if(jValue.has("lc")){
    tagInfo.categories = JsonUtils.parseEnum(jValue, "lc",LexicalCategory.class);
  } else {
    tagInfo.categories = EnumSet.noneOf(LexicalCategory.class);
  }
  if(jValue.has("pos")){
    tagInfo.pos = JsonUtils.parseEnum(jValue, "pos", Pos.class);
  } else {
    tagInfo.pos = EnumSet.noneOf(Pos.class);
  }
  PosTag posTag = posTagCache.get(tagInfo);
  if(posTag == null){
    posTag = new PosTag(tagInfo.tag,tagInfo.categories,tagInfo.pos);
    posTagCache.put(tagInfo, posTag);
  }
  return posTag;
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

public boolean mapHas(final String key) {
  if (!isMap()) {
    throw new IllegalStateException("does not represent map");
  }
  ObjectNode node = asObjectNode();
  final String[] paths = key.split("\\.");
  for (int i = 0; i < paths.length; i++) {
    final String path = paths[i];
    final boolean has = node.has(path);
    if (!has) {
      return false;
    }
    if (i + 1 < paths.length) {
      // not on last
      final JsonNode subNode = node.get(path);
      if (!subNode.isObject()) {
        return false;
      }
      node = (ObjectNode) subNode;
    }
  }
  return true;
}
origin: org.apache.isis.viewer/json-applib

public boolean mapHas(final String key) {
  if (!isMap()) {
    throw new IllegalStateException("does not represent map");
  }
  ObjectNode node = asObjectNode();
  final String[] paths = key.split("\\.");
  for (int i = 0; i < paths.length; i++) {
    final String path = paths[i];
    final boolean has = node.has(path);
    if (!has) {
      return false;
    }
    if (i + 1 < paths.length) {
      // not on last
      final JsonNode subNode = node.get(path);
      if (!subNode.isObject()) {
        return false;
      }
      node = (ObjectNode) subNode;
    }
  }
  return true;
}
origin: NGDATA/hbase-indexer

    new IndexerDefinitionBuilder().startFrom(oldIndexer)).build();
IndexerDefinition.LifecycleState lifecycleState = json.has("lifecycleState") ?
    IndexerDefinition.LifecycleState.valueOf(json.get("lifecycleState").getTextValue()) : null;
origin: com.ngdata/hbase-indexer-server

    new IndexerDefinitionBuilder().startFrom(oldIndexer)).build();
IndexerDefinition.LifecycleState lifecycleState = json.has("lifecycleState") ?
    IndexerDefinition.LifecycleState.valueOf(json.get("lifecycleState").getTextValue()) : null;
origin: eBay/YiDB

@Test
public void testProject06() {
  // case 0 : aggregation
  String query = "NetworkAddress<@healthState>{@healthState, $max(@address), $count()}";
  cmsdbContext.setAllowFullTableScan(true);
  cmsdbContext.setShowDisplayMeta(true);
  IQueryResult result = queryService.query(query, cmsdbContext);
  ArrayNode display = result.getDisplayMeta();
  ObjectNode na = (ObjectNode) display.get(0).get("fields");
  Assert.assertEquals(5, na.size());
  Assert.assertTrue(na.has("healthState"));
  Assert.assertTrue(na.has("$count"));
  Assert.assertTrue(na.has("$max_address"));
}
origin: eBay/YiDB

@Test
public void testQueryExplanation_typeCast2() {
  String query = "ResourceGroup.<ResourceGroup>children{*}";
  QueryContext qc = newQueryContext(CMSDB_REPO, IBranch.DEFAULT_BRANCH);
  qc.setAllowFullTableScan(true);
  qc.setExplain(true);
  IQueryResult queryResult = queryService.query(query, qc);
  Assert.assertNotNull(queryResult.getExplanations());
  List<IQueryExplanation> explans = queryResult.getExplanations();
  Assert.assertEquals(3, explans.size());
  // first two is search explanation, the last one is the join explanation
  ObjectNode objectNode = (ObjectNode) explans.get(0).getJsonExplanation();
  String queryType0 = objectNode.get("criteria").get("$and").get(0).get("_t").getTextValue();
  Assert.assertTrue(queryType0.equals("ResourceGroup"));
  Assert.assertTrue(objectNode.has("usedTime"));
  Assert.assertTrue(objectNode.has("limit"));
  Assert.assertTrue(objectNode.has("sort"));
  objectNode = (ObjectNode) explans.get(1).getJsonExplanation();
  String queryType1 = objectNode.get("criteria").get("$and").get(0).get("_t").getTextValue();
  Assert.assertTrue(queryType1.equals("ResourceGroup"));
}
origin: eBay/YiDB

@Test
public void testAggregationQuery_noFullTableScan() {
  String query = "Rack[@_oid=\"5199c9450cf2359a4ea29a62\"].assets<@resourceId>.asset!AssetServer";
  cmsdbContext.setAllowFullTableScan(false);
  cmsdbContext.setExplain(true);
  IQueryResult result = queryService.query(query, cmsdbContext);
  Assert.assertEquals(6, result.getEntities().size());
  List<IQueryExplanation> queryExplanation = result.getExplanations();
  JsonNode explainNode = queryExplanation.get(2).getJsonExplanation();
  Assert.assertEquals("AssetServer", explainNode.get("criteria").get("$and").get(0).get("_t").getTextValue());
  JsonNode refereInNode = explainNode.get("criteria").get("$and").get(2);
  Assert.assertNotNull(refereInNode);
  // FIXME: flatten will have different explanation
  if (cmsdbContext.getRegistration().registrationId.equals("hierarchy")) {
    String dbValueName = cmsdbMetaService.getMetaClass("AssetServer").getFieldByName("asset").getValueDbName()
        + "._i";
    Assert.assertTrue(((ObjectNode) refereInNode).has(dbValueName));
  }
}
origin: eBay/YiDB

@Test
public void testFieldProperty() {
  raptorContext.setAllowFullTableScan(true);
  String query = "ServiceInstance{@runsOn, @runsOn.$_lastmodified}";
  IQueryResult result = queryService.query(query, raptorContext);
  Assert.assertEquals(12, result.getEntities().size());
  int noRunsOnCount = 0;
  for (IEntity serv : result.getEntities()) {
    if (!serv.hasField("runsOn")) {
      noRunsOnCount++;
    } else {
      Assert.assertTrue(((JsonEntity) serv).getNode().has("runsOn"));
      Assert.assertTrue(((JsonEntity) serv).getNode().has("runsOn._lastmodified"));
    }
  }
  Assert.assertEquals(1, noRunsOnCount);
}
origin: eBay/YiDB

/**
 * CMS 3617 ::
 */
@Test
@SuppressWarnings("unchecked")
public void testLeftReverse() {
  cmsdbContext.setAllowFullTableScan(true);
  String query = "Rack{*}+.assets[@assetType=\"Server\"]{@resourceId,@assetType,@healthState,@healthState,@_lastmodified,@manufacturer,@locationCode}.asset!AssetServer{@resourceId}";
  IQueryResult result = queryService.query(query, cmsdbContext);
  Assert.assertEquals(1, result.getEntities().size());
  IEntity rack = result.getEntities().get(0);
  List<JsonEntity> assets = (List<JsonEntity>) rack.getFieldValues("assets");
  Assert.assertEquals(7, assets.size());
  int assetWihtoutAssetServerCount = 0;
  int assetWithAssetServerCount = 0;
  for (JsonEntity asset : assets) {
    if (!asset.getNode().has("asset!AssetServer")) {
      assetWihtoutAssetServerCount++;
    } else {
      assetWithAssetServerCount++;
    }
  }
  Assert.assertEquals(1, assetWihtoutAssetServerCount);
  Assert.assertEquals(assets.size() - assetWihtoutAssetServerCount, assetWithAssetServerCount);
}
origin: NGDATA/lilyproject

if (node.has("valueType") && node.get("valueType").isObject() && node.get("valueType").has("primitive")) {
  throw new JsonFormatException("Lily 1.1 format change: the valueType should now be specified as a string" +
      " rather than a nested object with the 'primitive' property.");
origin: PeterKnego/LeanEngine-Server

public JsonNode toJson() throws LeanException {
  ObjectNode json = JsonUtils.getObjectMapper().createObjectNode();
  json.put("kind", kind);
  if (!filters.isEmpty()) {
    ObjectNode jsonFilters = JsonUtils.getObjectMapper().createObjectNode();
    for (QueryFilter filter : filters) {
      ObjectNode jsonFilter;
      if (jsonFilters.has(filter.getProperty())) {
        jsonFilter = (ObjectNode) jsonFilters.get(filter.getProperty());
      } else {
        jsonFilter = JsonUtils.getObjectMapper().createObjectNode();
      }
      JsonUtils.addTypedNode(jsonFilter, filter.getOperator().toJSON(), filter.getValue());
      jsonFilters.put(filter.getProperty(), jsonFilter);
    }
    json.put("filter", jsonFilters);
  }
  if (!sorts.isEmpty()) {
    ObjectNode jsonSorts = JsonUtils.getObjectMapper().createObjectNode();
    for (QuerySort sort : sorts) {
      jsonSorts.put(sort.getProperty(), sort.getDirection().toJSON());
    }
    json.put("sort", jsonSorts);
  }
  if (this.cursor != null) {
    json.put("cursor", cursor.toWebSafeString());
  }
  return json;
}
origin: rdelbru/SIREn

for (final QueryClause clause : clauses) {
 if (clause instanceof BasicQueryClause) {
  if (!twig.has(ChildPropertyParser.CHILD_PROPERTY)) { // avoid to create an empty array in the JSON
   childArray = twig.putArray(ChildPropertyParser.CHILD_PROPERTY);
  if (!twig.has(DescendantPropertyParser.DESCENDANT_PROPERTY)) { // avoid to create an empty array in the JSON
   descendantArray = twig.putArray(DescendantPropertyParser.DESCENDANT_PROPERTY);
org.codehaus.jackson.nodeObjectNodehas

Popular methods of ObjectNode

  • put
    Method for setting value of a field to specified binary value
  • get
  • getFields
    Method to use for accessing all fields (with both names and values) of this JSON Object.
  • toString
  • putArray
    Method that will construct an ArrayNode and add it as a field of this ObjectNode, replacing old valu
  • remove
    Method for removing specified field properties out of this ObjectNode.
  • objectNode
  • size
  • <init>
  • arrayNode
  • putObject
    Method that will construct an ObjectNode and add it as a field of this ObjectNode, replacing old val
  • nullNode
  • putObject,
  • nullNode,
  • path,
  • putNull,
  • POJONode,
  • _put,
  • binaryNode,
  • booleanNode,
  • equals

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • startActivity (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Table (org.hibernate.mapping)
    A relational table
  • Runner (org.openjdk.jmh.runner)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now