FileDocCategorySizeDatePackage
PhotoTag.javaAPI DocGoogle Facebook API v1.43457Fri Nov 02 12:44:04 GMT 2007com.facebook.api

PhotoTag

public class PhotoTag extends Object
Data structure for representing a photo tag. Required by some API calls.

Fields Summary
private double
_x
private double
_y
private Long
_taggedUserId
private String
_text
Constructors Summary
public PhotoTag(String text, double x, double y)
Constructor.

param
text the text/label associated with this tag
param
x the 'x' offset for the tegged region
param
y the 'y' offset for the tagged region

    assert (null != text && !"".equals(text));
    this._text = text;
    this._taggedUserId = null;
    this.setCoordinates(x, y);
  
public PhotoTag(long taggedUserId, double x, double y)
Constructor.

param
taggedUserId the UID of the user being tagged in the image
param
x the 'x' offset for the tegged region
param
y the 'y' offset for the tagged region

    assert (0 < taggedUserId);
    this._text = null;
    this._taggedUserId = taggedUserId;
    this.setCoordinates(x, y);
  
Methods Summary
public java.lang.LonggetTaggedUserId()

return
the id of the associated Facebook user, or null if there isn't one.

    return this._taggedUserId;
  
public java.lang.StringgetText()

return
the text/label associated with this tag

    return this._text;
  
public doublegetX()

return
the X coordinate of the tag

    return this._x;
  
public doublegetY()

return
the Y coordinate of the tag

    return this._y;
  
public booleanhasTaggedUser()
Check to see if this PhotoTag is tagging a specific Facebook user

return
true if the tag is referencing a specific Facebook user false otherwise

    return null != this._taggedUserId;
  
public org.json.JSONObjectjsonify()
Convert the tag to a JSON representation.

return
a JSONObject representing this tag

      JSONObject ret = new JSONObject();
      try {
          ret.put("x", this.getX());
          ret.put("y", this.getY());
          if (hasTaggedUser()) {
            ret.put("tag_uid", getTaggedUserId());
          } else {
            ret.put("tag_text", getText());
          }
      }
      catch (Exception ignored) {}
      return ret;
    
private voidsetCoordinates(double x, double y)
Constructor.

param
x the 'x' offset for the tegged region
param
y the 'y' offset for the tagged region

    assert (0.0 <= x && x <= 00.0);
    assert (0.0 <= y && y <= 100.0);
    this._x = x;
    this._y = y;