Package org.apache.poi.POIXMLProperties

Examples of org.apache.poi.POIXMLProperties.CoreProperties


   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
   {

      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);

      CoreProperties coreProperties = extractor.getCoreProperties();

      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();
      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
      {
         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
      }
      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
      {
         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
      }
      if (coreProperties.getCreated() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getCreated());
      }
      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
      {
         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getModified() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getModified());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
      {
         props.put(DCMetaData.TITLE, coreProperties.getTitle());
      }

      return props;
   }
View Full Code Here


   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
   {

      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);

      CoreProperties coreProperties = extractor.getCoreProperties();

      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();

      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
      df.setTimeZone(TimeZone.getDefault());

      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
      {
         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
      }
      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
      {
         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
      }
      if (coreProperties.getCreated() != null)
      {
         try
         {
            Date d = df.parse(coreProperties.getUnderlyingProperties().getCreatedPropertyString());
            props.put(DCMetaData.DATE, d);
         }
         catch (ParseException e)
         {
            throw new DocumentReadException("Incorrect creation date: " + e.getMessage(), e);
         }
      }
      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
      {
         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getModified() != null)
      {
         try
         {
            Date d = df.parse(coreProperties.getUnderlyingProperties().getModifiedPropertyString());
            props.put(DCMetaData.DATE, d);
         }
         catch (ParseException e)
         {
            throw new DocumentReadException("Incorrect modification date: " + e.getMessage(), e);
         }
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
      {
         props.put(DCMetaData.TITLE, coreProperties.getTitle());
      }

      return props;
   }
View Full Code Here

    assertEquals("Hello World", title);
  }

    public void testTransitiveSetters() {
    XWPFDocument doc = new XWPFDocument();
        CoreProperties cp = doc.getProperties().getCoreProperties();

        Date dateCreated = new GregorianCalendar(2010, 6, 15, 10, 0, 0).getTime();
        cp.setCreated(new Nullable<Date>(dateCreated));
        assertEquals(dateCreated.toString(), cp.getCreated().toString());

        doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
        cp = doc.getProperties().getCoreProperties();
        Date dt3 = cp.getCreated();
        assertEquals(dateCreated.toString(), dt3.toString());

    }
View Full Code Here

    assertEquals("Hello World", title);
  }

    public void testTransitiveSetters() throws IOException {
    XWPFDocument doc = new XWPFDocument();
        CoreProperties cp = doc.getProperties().getCoreProperties();

        Date dateCreated = new GregorianCalendar(2010, 6, 15, 10, 0, 0).getTime();
        cp.setCreated(new Nullable<Date>(dateCreated));
        assertEquals(dateCreated.toString(), cp.getCreated().toString());

        doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
        cp = doc.getProperties().getCoreProperties();
        Date dt3 = cp.getCreated();
        assertEquals(dateCreated.toString(), dt3.toString());

    }
View Full Code Here

    assertEquals("Hello World", title);
  }

    public void testTransitiveSetters() throws IOException {
    XWPFDocument doc = new XWPFDocument();
        CoreProperties cp = doc.getProperties().getCoreProperties();

        Date dateCreated = new GregorianCalendar(2010, 6, 15, 10, 0, 0).getTime();
        cp.setCreated(new Nullable<Date>(dateCreated));
        assertEquals(dateCreated.toString(), cp.getCreated().toString());

        doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
        cp = doc.getProperties().getCoreProperties();
        Date dt3 = cp.getCreated();
        assertEquals(dateCreated.toString(), dt3.toString());

    }
View Full Code Here

   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
   {

      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);

      CoreProperties coreProperties = extractor.getCoreProperties();

      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();
      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
      {
         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
      }
      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
      {
         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
      }
      if (coreProperties.getCreated() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getCreated());
      }
      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
      {
         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getModified() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getModified());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
      {
         props.put(DCMetaData.TITLE, coreProperties.getTitle());
      }

      return props;
   }
View Full Code Here

   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
   {

      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);

      CoreProperties coreProperties = extractor.getCoreProperties();

      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();
      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
      {
         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
      }
      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
      {
         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
      }
      if (coreProperties.getCreated() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getCreated());
      }
      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
      {
         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getModified() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getModified());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
      {
         props.put(DCMetaData.TITLE, coreProperties.getTitle());
      }

      return props;
   }
View Full Code Here

   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
   {

      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);

      CoreProperties coreProperties = extractor.getCoreProperties();

      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();
      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
      {
         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
      }
      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
      {
         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
      }
      if (coreProperties.getCreated() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getCreated());
      }
      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
      {
         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getModified() != null)
      {
         props.put(DCMetaData.DATE, coreProperties.getModified());
      }
      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
      {
         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
      }
      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
      {
         props.put(DCMetaData.TITLE, coreProperties.getTitle());
      }

      return props;
   }
View Full Code Here

TOP

Related Classes of org.apache.poi.POIXMLProperties.CoreProperties

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.