Package serializers.java

Examples of serializers.java.Image


  {


    public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context)
    {
      Image image = (Image) obj;
      writer.addAttribute("ul", image.getUri());
      writer.addAttribute("tl", image.getTitle());
      writer.addAttribute("wd", String.valueOf(image.getWidth()));
      writer.addAttribute("hg", String.valueOf(image.getHeight()));
      writer.addAttribute("sz", String.valueOf(image.getSize().ordinal()));
    }
View Full Code Here


    }


    public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
    {
      Image image = new Image();
      image.setUri(reader.getAttribute("ul"));
      image.setTitle(reader.getAttribute("tl"));
      image.setWidth(Integer.valueOf(reader.getAttribute("wd")));
      image.setHeight(Integer.valueOf(reader.getAttribute("hg")));
      image.setSize(Size.values()[Integer.valueOf(reader.getAttribute("sz"))]);
      return image;
    }
View Full Code Here

    return content;
  }

  private Image readImage (XMLStreamReader parser) throws Exception
  {
    Image image = new Image();
    image.setUri(readElement(parser, FIELD_NAME_URI));
    image.setTitle(readElement(parser, FIELD_NAME_TITLE));
    image.setWidth(Integer.parseInt(readElement(parser, FIELD_NAME_WIDTH)));
    image.setHeight(Integer.parseInt(readElement(parser, FIELD_NAME_HEIGHT)));
    image.setSize(Size.valueOf(readElement(parser, FIELD_NAME_SIZE)));
    // need to match close tag
    if (parser.nextTag() != XMLStreamConstants.END_ELEMENT) {
        throw new IllegalStateException("Expected closing </"+FIELD_NAME_IMAGES+">");
    }
    return image;
View Full Code Here

  }

  private final Image readImage(JsonParser parser) throws IOException
  {
      JsonToken t;
      Image image = new Image();
     
      while ((t = parser.nextToken()) != JsonToken.END_OBJECT) {
          if (t != JsonToken.FIELD_NAME) {
              reportIllegal(parser, JsonToken.FIELD_NAME);
          }
          String field = parser.getCurrentName();
          // read value token (or START_ARRAY)
          t = parser.nextToken();
          Integer I = fieldToIndex.get(field);
          if (I != null) {
              switch (I.intValue()) {
              case FIELD_IX_URI:
                  image.setUri(parser.getText());
                  continue;
              case FIELD_IX_TITLE:
                  image.setTitle(parser.getText());
                  continue;
              case FIELD_IX_WIDTH:
                  image.setWidth(parser.getIntValue());
                  continue;
              case FIELD_IX_HEIGHT:
                  image.setHeight(parser.getIntValue());
                  continue;
              case FIELD_IX_SIZE:
                  image.setSize(Image.Size.valueOf(parser.getText()));
                  continue;
              }
          }
          throw new IllegalStateException("Unexpected field '"+field+"'");
      }
View Full Code Here

    {
        Media media = new Media(null, "video/mpg4", Media.Player.JAVA, "Javaone Keynote", "http://javaone.com/keynote.mpg", 1234567, 123, 0, 0, 0);
        media.addToPerson("Bill Gates");
        media.addToPerson("Steve Jobs");
        MediaContent content = new MediaContent(media);
        content.addImage(new Image(0, "Javaone Keynote", "http://javaone.com/keynote_large.jpg", 0, Image.Size.LARGE));
        content.addImage(new Image(0, "Javaone Keynote", "http://javaone.com/keynote_thumbnail.jpg", 0, Image.Size.SMALL));
        return content;
    }
View Full Code Here

TOP

Related Classes of serializers.java.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.