Package org.apache.poi.hpsf

Examples of org.apache.poi.hpsf.CustomProperties


    si.setTitle(title);
    si.setAuthor(author);
    si.setComments(comments);
    si.setKeywords(keywords);
    si.setSubject(subject);
    CustomProperties customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      customProperties = new CustomProperties();
    }

    /* Insert some custom properties into the container. */
    customProperties.put(k1, p1);
    customProperties.put(k2, p2);
    customProperties.put("Sample Number", new Integer(12345));
    customProperties.put("Sample Boolean", Boolean.FALSE);
    Date date = new Date(0);
    customProperties.put("Sample Date", date);

    dsi.setCustomProperties(customProperties);

    closeAndReOpen();

    assertNotNull(dsi);
    assertNotNull(si);
    /*
     * Change the category to "POI example". Any former category value will
     * be lost. If there has been no category yet, it will be created.
     */
    assertEquals("Category", category, dsi.getCategory());
    assertEquals("Company", company, dsi.getCompany());
    assertEquals("Manager", manager, dsi.getManager());

    assertEquals("", author, si.getAuthor());
    assertEquals("", title, si.getTitle());
    assertEquals("", comments, si.getComments());
    assertEquals("", keywords, si.getKeywords());
    assertEquals("", subject, si.getSubject());

    /*
     * Read the custom properties. If there are no custom properties yet,
     * the application has to create a new CustomProperties object. It will
     * serve as a container for custom properties.
     */
    customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      fail();
    }

    /* Insert some custom properties into the container. */
    // System.out.println(k1);
    String a1 = (String) customProperties.get(k1);
    assertEquals("Key1", p1, a1);
    String a2 = (String) customProperties.get(k2);
    assertEquals("Schl\u00fcssel2", p2, a2);
    Integer a3 = (Integer) customProperties.get("Sample Number");
    assertEquals("Sample Number", new Integer(12345), a3);
    Boolean a4 = (Boolean) customProperties.get("Sample Boolean");
    assertEquals("Sample Boolean", Boolean.FALSE, a4);
    Date a5 = (Date) customProperties.get("Sample Date");
    assertEquals("Custom Date:", date, a5);

  }
View Full Code Here


    si.setTitle(title);
    si.setAuthor(author);
    si.setComments(comments);
    si.setKeywords(keywords);
    si.setSubject(subject);
    CustomProperties customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      customProperties = new CustomProperties();
    }

    /* Insert some custom properties into the container. */
    customProperties.put(k1, p1);
    customProperties.put(k2, p2);
    customProperties.put("Sample Number", new Integer(12345));
    customProperties.put("Sample Boolean", Boolean.TRUE);
    Date date = new Date();
    customProperties.put("Sample Date", date);

    dsi.setCustomProperties(customProperties);

    closeAndReOpen();

    assertNotNull(dsi);
    assertNotNull(si);
    /*
     * Change the category to "POI example". Any former category value will
     * be lost. If there has been no category yet, it will be created.
     */
    assertEquals("Category", category, dsi.getCategory());
    assertEquals("Company", company, dsi.getCompany());
    assertEquals("Manager", manager, dsi.getManager());

    assertEquals("", author, si.getAuthor());
    assertEquals("", title, si.getTitle());
    assertEquals("", comments, si.getComments());
    assertEquals("", keywords, si.getKeywords());
    assertEquals("", subject, si.getSubject());

    /*
     * Read the custom properties. If there are no custom properties yet,
     * the application has to create a new CustomProperties object. It will
     * serve as a container for custom properties.
     */
    customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      fail();
    }

    /* Insert some custom properties into the container. */
    // System.out.println(k1);
    String a1 = (String) customProperties.get(k1);
    assertEquals("Key1", p1, a1);
    String a2 = (String) customProperties.get(k2);
    assertEquals("Schl\u00fcssel2", p2, a2);
    Integer a3 = (Integer) customProperties.get("Sample Number");
    assertEquals("Sample Number", new Integer(12345), a3);
    Boolean a4 = (Boolean) customProperties.get("Sample Boolean");
    assertEquals("Sample Boolean", Boolean.TRUE, a4);
    Date a5 = (Date) customProperties.get("Sample Date");
    assertEquals("Custom Date:", date, a5);
  }
View Full Code Here

  /**
   * Tests conversion in custom fields and errors
   */
  public void testConvAndExistence() {

    CustomProperties customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      customProperties = new CustomProperties();
    }

    /* Insert some custom properties into the container. */
    customProperties.put("int", new Integer(12345));
    customProperties.put("negint", new Integer(-12345));
    customProperties.put("long", new Long(12345));
    customProperties.put("neglong", new Long(-12345));
    customProperties.put("boolean", Boolean.TRUE);
    customProperties.put("string", "a String");
    // customProperties.put("float", new Float(12345.0)); is not valid
    // customProperties.put("negfloat", new Float(-12345.1)); is not valid
    customProperties.put("double", new Double(12345.2));
    customProperties.put("negdouble", new Double(-12345.3));
    // customProperties.put("char", new Character('a')); is not valid

    Date date = new Date();
    customProperties.put("date", date);

    dsi.setCustomProperties(customProperties);

    closeAndReOpen();

    assertNotNull(dsi);
    assertNotNull(si);
    /*
     * Change the category to "POI example". Any former category value will
     * be lost. If there has been no category yet, it will be created.
     */
    assertNull(dsi.getCategory());
    assertNull(dsi.getCompany());
    assertNull(dsi.getManager());

    assertNull(si.getAuthor());
    assertNull(si.getTitle());
    assertNull(si.getComments());
    assertNull(si.getKeywords());
    assertNull(si.getSubject());

    /*
     * Read the custom properties. If there are no custom properties yet,
     * the application has to create a new CustomProperties object. It will
     * serve as a container for custom properties.
     */
    customProperties = dsi.getCustomProperties();
    if (customProperties == null) {
      fail();
    }

    /* Insert some custom properties into the container. */

    Integer a3 = (Integer) customProperties.get("int");
    assertEquals("int", new Integer(12345), a3);

    a3 = (Integer) customProperties.get("negint");
    assertEquals("negint", new Integer(-12345), a3);

    Long al = (Long) customProperties.get("neglong");
    assertEquals("neglong", new Long(-12345), al);

    al = (Long) customProperties.get("long");
    assertEquals("long", new Long(12345), al);

    Boolean a4 = (Boolean) customProperties.get("boolean");
    assertEquals("boolean", Boolean.TRUE, a4);

    Date a5 = (Date) customProperties.get("date");
    assertEquals("Custom Date:", date, a5);

    Double d = (Double) customProperties.get("double");
    assertEquals("int", new Double(12345.2), d);

    d = (Double) customProperties.get("negdouble");
    assertEquals("string", new Double(-12345.3), d);

    String s = (String) customProperties.get("string");
    assertEquals("sring", "a String", s);


    assertTrue(customProperties.get("string") instanceof String);
    assertTrue(customProperties.get("boolean") instanceof Boolean);
    assertTrue(customProperties.get("int") instanceof Integer);
    assertTrue(customProperties.get("negint") instanceof Integer);
    assertTrue(customProperties.get("long") instanceof Long);
    assertTrue(customProperties.get("neglong") instanceof Long);
    assertTrue(customProperties.get("double") instanceof Double);
    assertTrue(customProperties.get("negdouble") instanceof Double);
    assertTrue(customProperties.get("date") instanceof Date);
  }
View Full Code Here

       
        parse(summary.getCustomProperties());
    }

    private String getLanguage(DocumentSummaryInformation summary) {
        CustomProperties customProperties = summary.getCustomProperties();
        if (customProperties != null) {
            Object value = customProperties.get("Language");
            if (value instanceof String) {
                return (String) value;
            }
        }
        return null;
View Full Code Here

       
        parse(summary.getCustomProperties());
    }

    private String getLanguage(DocumentSummaryInformation summary) {
        CustomProperties customProperties = summary.getCustomProperties();
        if (customProperties != null) {
            Object value = customProperties.get("Language");
            if (value instanceof String) {
                return (String) value;
            }
        }
        return null;
View Full Code Here

       
        parse(summary.getCustomProperties());
    }

    private String getLanguage(DocumentSummaryInformation summary) {
        CustomProperties customProperties = summary.getCustomProperties();
        if (customProperties != null) {
            Object value = customProperties.get("Language");
            if (value instanceof String) {
                return (String) value;
            }
        }
        return null;
View Full Code Here

       
        parse(summary.getCustomProperties());
    }

    private String getLanguage(DocumentSummaryInformation summary) {
        CustomProperties customProperties = summary.getCustomProperties();
        if (customProperties != null) {
            Object value = customProperties.get("Language");
            if (value instanceof String) {
                return (String) value;
            }
        }
        return null;
View Full Code Here

TOP

Related Classes of org.apache.poi.hpsf.CustomProperties

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.