Package com.drew.metadata

Examples of com.drew.metadata.Tag


        while (directories.hasNext()) {
            Directory directory = (Directory)directories.next();
            // iterate through tags
            Iterator tags = directory.getTagIterator();
            while (tags.hasNext()) {
                Tag tag = (Tag)tags.next();
                exifBuf.append(tag.getTagName().toString());
                exifBuf.append("=");
               
                try{
                    exifBuf.append(URLUTF8Encoder.encode(tag.getDescription()));
                }catch(Exception e){
                    //return;
                }

                if(tags.hasNext()){
View Full Code Here


            while (directories.hasNext()) {
                Directory directory = directories.next();
                String dir = directory.getName();
                Iterator<Tag> tags = directory.getTags().iterator();
                while (tags.hasNext()) {
                    Tag tag = tags.next();

                    tree.addStartElement(c_tag);
                    tree.addAttribute(_dir, dir);
                    tree.addAttribute(_type, tag.getTagTypeHex());
                    tree.addAttribute(_name, tag.getTagName());

                    String value = tag.getDescription();

                    // Laboriously escape all the control characters with \\uxxxx, but first replace
                    // \\uxxxx with \\u005cuxxxx so we don't inadvertantly change the meaning of a string
                    value = value.replaceAll("\\\\u([0-9a-fA-F]{4}+)", "\\\\u005cu$1");
                    for (String control : controls) {
View Full Code Here

      Iterator directories = metadata.getDirectoryIterator();
      while (directories.hasNext()) {
        Directory directory = (Directory)directories.next();
        Iterator tags = directory.getTagIterator();
        while (tags.hasNext()) {
          Tag tag = (Tag)tags.next();
          header.addEXIFInformation(tag.getTagName(), tag.getDescription());
        }
      }
    } catch (Exception e) {
    }
    return header;
View Full Code Here

        Struct sct=new StructImpl();
        info.setEL(KeyImpl.init(directory.getName()), sct);
       
        Iterator<Tag> tags = directory.getTagIterator();
        while (tags.hasNext()) {
            Tag tag = tags.next();
            sct.setEL(KeyImpl.init(tag.getTagName()), tag.getDescription());
        }
    }
  }
View Full Code Here

        }
        public void handle(Directory directory, Metadata metadata)
                throws MetadataException {
            Iterator<?> tags = directory.getTagIterator();
            while (tags.hasNext()) {
                Tag tag = (Tag) tags.next();
                metadata.set(tag.getTagName(), tag.getDescription());
            }
        }
View Full Code Here

        }
        public void handle(Directory directory, Metadata metadata)
                throws MetadataException {
            Iterator<?> tags = directory.getTagIterator();
            while (tags.hasNext()) {
                Tag tag = (Tag) tags.next();
                String name = tag.getTagName();
                if (!MetadataFields.isMetadataField(name)) {
                   try {
                      String value = tag.getDescription().trim();
                      if (Boolean.TRUE.toString().equalsIgnoreCase(value)) {
                          value = Boolean.TRUE.toString();
                      } else if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
                          value = Boolean.FALSE.toString();
                      }
View Full Code Here

                metadata.get(TikaCoreProperties.CREATED));
    }
   
    public void testCopyUnknownFieldsHandler() throws MetadataException {
        Directory d = mock(Directory.class);
        Tag t1 = mock(Tag.class);
        when(t1.getTagName()).thenReturn("Image Description");
        when(t1.getDescription()).thenReturn("t1");
        Tag t2 = mock(Tag.class);
        when(t2.getTagName()).thenReturn(Metadata.KEYWORDS);
        when(t2.getDescription()).thenReturn("known");
        Tag t3 = mock(Tag.class);
        when(t3.getTagName()).thenReturn(TikaCoreProperties.DESCRIPTION.getName());
        when(t3.getDescription()).thenReturn("known");
        Iterator<Tag> tags = Arrays.asList(t1, t2, t3).iterator();
        when(d.getTagIterator()).thenReturn(tags);
        Metadata metadata = new Metadata();
        new ImageMetadataExtractor.CopyUnknownFieldsHandler().handle(d, metadata);
        assertEquals("t1", metadata.get("Image Description"));
View Full Code Here

        assertEquals("Parsing should proceed without date", null, metadata.get(DublinCore.DATE));
    }
   
    public void testCopyUnknownFieldsHandler() throws MetadataException {
        Directory d = mock(Directory.class);
        Tag t1 = mock(Tag.class);
        when(t1.getTagName()).thenReturn("Image Description");
        when(t1.getDescription()).thenReturn("t1");
        Tag t2 = mock(Tag.class);
        when(t2.getTagName()).thenReturn(Metadata.KEYWORDS);
        when(t2.getDescription()).thenReturn("known");
        Tag t3 = mock(Tag.class);
        when(t3.getTagName()).thenReturn(Metadata.DESCRIPTION);
        when(t3.getDescription()).thenReturn("known");
        Iterator<Tag> tags = Arrays.asList(t1, t2, t3).iterator();
        when(d.getTagIterator()).thenReturn(tags);
        Metadata metadata = new Metadata();
        new ImageMetadataExtractor.CopyUnknownFieldsHandler().handle(d, metadata);
        assertEquals("t1", metadata.get("Image Description"));
View Full Code Here

                    final Directory directory = directories.next();
                    @SuppressWarnings("unchecked")
                    final
                    Iterator<Tag> tags = directory.getTagIterator();
                    while (tags.hasNext()) {
                        final Tag tag = tags.next();
                        try {
                            props.put(tag.getTagName(), tag.getDescription());
                            ii.info.append(tag.getTagName() + ": " + tag.getDescription() + " .\n");
                        } catch (final MetadataException e) {
                            //Log.logException(e);
                        }
                    }
                    title = props.get("Image Description");
View Full Code Here

        Iterator directories = metadata.getDirectoryIterator();
        while (directories.hasNext()) {
            Directory directory = (Directory)directories.next();
            Iterator tags = directory.getTagIterator();
            while (tags.hasNext()) {
                Tag tag = (Tag)tags.next();
                try {
                    System.out.println("[" + directory.getName() + "] " + tag.getTagName() + " = " + tag.getDescription());
                } catch (MetadataException e) {
                    System.err.println(e.getMessage());
                    System.err.println(tag.getDirectoryName() + " " + tag.getTagName() + " (error)");
                }
            }
            if (directory.hasErrors()) {
                Iterator errors = directory.getErrors();
                while (errors.hasNext()) {
View Full Code Here

TOP

Related Classes of com.drew.metadata.Tag

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.