コード例 #1
0
ファイル: Photo.java プロジェクト: Ajapaik/sift-pics-android
  public Photo(JsonObject attributes, Photo basePhoto) {
    m_identifier = readIdentifier(attributes, KEY_IDENTIFIER);
    m_image = readUri(attributes, KEY_IMAGE, (basePhoto != null) ? basePhoto.getImage() : null);
    m_title = readString(attributes, KEY_TITLE, (basePhoto != null) ? basePhoto.getTitle() : null);
    m_author =
        readString(attributes, KEY_AUTHOR, (basePhoto != null) ? basePhoto.getAuthor() : null);
    m_source =
        readHyperlink(attributes, KEY_SOURCE, (basePhoto != null) ? basePhoto.getSource() : null);
    m_tags = new ArrayList<Tag>();

    // FIXME: "tag" is just a temporary workaround for a server-side bug
    for (JsonElement tagElement :
        readArray(attributes, (attributes.has("tag")) ? "tag" : KEY_TAGS)) {
      if (tagElement.isJsonPrimitive()) {
        JsonPrimitive tagPrimitive = tagElement.getAsJsonPrimitive();
        String tagName = (tagPrimitive.isString()) ? tagPrimitive.getAsString() : null;

        if (tagName != null) {
          Tag tag = Tag.parse(tagName);

          if (tag != Tag.UNKNOWN) {
            m_tags.add(tag);
          }
        }
      }
    }

    if (m_identifier == null || m_image == null) {
      throw new IllegalArgumentException();
    }
  }
コード例 #2
0
  @Override
  public void parse() {
    super.parse();

    if (!allowChildParse) {
      return;
    }
    rgb = new RGB(buffer, null);
    rgb.read();
  }
コード例 #3
0
 @Override
 public Tag apply(String input) {
   return Tag.parse(input);
 }