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


Java Tag類代碼示例

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


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

示例1: parseArg

import com.mongodb.Tag; //導入依賴的package包/類
private static TagSet parseArg(ObjectNode arg) {
    List<Tag> tags = new ArrayList<>();
    for (Iterator<Map.Entry<String, JsonNode>> itr = arg.fields(); itr.hasNext();) {
        Map.Entry<String, JsonNode> entry = itr.next();
        tags.add(new Tag(entry.getKey(), entry.getValue().asText()));
    }
    return new TagSet(tags);
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-mongo,代碼行數:9,代碼來源:MongoReadPreference.java

示例2: ReadPreferenceParser

import com.mongodb.Tag; //導入依賴的package包/類
ReadPreferenceParser(ConnectionString connectionString, JsonObject config) {
  ReadPreference connStringReadPreference = connectionString != null ? connectionString.getReadPreference() : null;
  if (connStringReadPreference != null) {
    // Prefer connection string's read preference
    readPreference = connStringReadPreference;
  } else {
    ReadPreference rp;
    String rps = config.getString("readPreference");
    if (rps != null) {
      JsonArray readPreferenceTags = config.getJsonArray("readPreferenceTags");
      if (readPreferenceTags == null) {
        rp = ReadPreference.valueOf(rps);
        if (rp == null) throw new IllegalArgumentException("Invalid ReadPreference " + rps);
      } else {
        // Support advanced ReadPreference Tags
        List<TagSet> tagSet = new ArrayList<>();
        readPreferenceTags.forEach(o -> {
          String tagString = (String) o;
          List<Tag> tags = Stream.of(tagString.trim().split(","))
              .map(s -> s.split(":"))
              .filter(array -> {
                if (array.length != 2) {
                  throw new IllegalArgumentException("Invalid readPreferenceTags value '" + tagString + "'");
                }
                return true;
              }).map(array -> new Tag(array[0], array[1])).collect(Collectors.toList());

          tagSet.add(new TagSet(tags));
        });
        rp = ReadPreference.valueOf(rps, tagSet);
      }
    } else {
      rp = null;
    }

    readPreference = rp;
  }
}
 
開發者ID:vert-x3,項目名稱:vertx-mongo-client,代碼行數:39,代碼來源:ReadPreferenceParser.java

示例3: toTags

import com.mongodb.Tag; //導入依賴的package包/類
private static TagSet toTags( DBObject tagsDocument )
{
	List<Tag> tagList = new ArrayList<Tag>( );
	for ( String key : tagsDocument.keySet( ) )
	{
		tagList.add( new Tag( key, tagsDocument.get( key ).toString( ) ) );
	}
	return new TagSet( tagList );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:10,代碼來源:QueryProperties.java

示例4: testNearestArgs

import com.mongodb.Tag; //導入依賴的package包/類
@Test
public void testNearestArgs() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest ( {\"x\":1} )");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(new TagSet(Arrays.asList(new Tag("x", "1"))))));
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-mongo,代碼行數:6,代碼來源:MongoReadPreferenceTest.java

示例5: testNearestArgs2

import com.mongodb.Tag; //導入依賴的package包/類
@Test
public void testNearestArgs2() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest ( [ {\"x\":1}, {\"y\":\"a\"}] )");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(Arrays.asList(new TagSet(Arrays.asList(new Tag("x", "1"))),
            new TagSet(Arrays.asList(new Tag("y", "a")))))));
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-mongo,代碼行數:7,代碼來源:MongoReadPreferenceTest.java

示例6: testNearestArgs3

import com.mongodb.Tag; //導入依賴的package包/類
@Test
public void testNearestArgs3() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest([ {\"x\":1}, {\"y\":\"a\"}])");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(Arrays.asList(new TagSet(Arrays.asList(new Tag("x", "1"))),
            new TagSet(Arrays.asList(new Tag("y", "a")))))));
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-mongo,代碼行數:7,代碼來源:MongoReadPreferenceTest.java


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