/** * @return the section's size in bytes. */ public int getSize() { int size = sectionBytes.size(); if (size > 0) { return size; } try { return calcSize(); } catch (HPSFRuntimeException ex) { throw ex; } catch (Exception ex) { throw new HPSFRuntimeException(ex); } }
/** * @see Throwable#printStackTrace(java.io.PrintStream) */ public void printStackTrace(final PrintStream p) { final Throwable reason = getReason(); super.printStackTrace(p); if (reason != null) { p.println("Caused by:"); reason.printStackTrace(p); } }
/** * @see Throwable#printStackTrace() */ public void printStackTrace() { printStackTrace(System.err); }
/** * @see Throwable#printStackTrace(java.io.PrintWriter) */ public void printStackTrace(final PrintWriter p) { final Throwable reason = getReason(); super.printStackTrace(p); if (reason != null) { p.println("Caused by:"); reason.printStackTrace(p); } }
/** * Returns the value of the numeric property with the specified * ID. If the property is not available, 0 is returned. A * subsequent call to {@link #wasNull} will return * {@code true} to let the caller distinguish that case from * a real property value of 0. * * @param id The property's ID * * @return The property's value */ int getPropertyIntValue(final long id) { final Number i; final Object o = getProperty(id); if (o == null) { return 0; } if (!(o instanceof Long || o instanceof Integer)) { throw new HPSFRuntimeException ("This property is not an integer type, but " + o.getClass().getName() + "."); } i = (Number) o; return i.intValue(); }
final Throwable cause = ex.getReason(); if (cause instanceof UnsupportedEncodingException) { throw new IllegalPropertySetDataException(cause);
/** * Sets a property. * * @param id The property ID. * @param value The property's value. The value's class must be one of those * supported by HPSF. */ public void setProperty(final int id, final Object value) { if (value instanceof String) { setProperty(id, (String) value); } else if (value instanceof Long) { setProperty(id, ((Long) value).longValue()); } else if (value instanceof Integer) { setProperty(id, ((Integer) value).intValue()); } else if (value instanceof Short) { setProperty(id, ((Short) value).intValue()); } else if (value instanceof Boolean) { setProperty(id, ((Boolean) value).booleanValue()); } else if (value instanceof Date) { setProperty(id, Variant.VT_FILETIME, value); } else { throw new HPSFRuntimeException( "HPSF does not support properties of type " + value.getClass().getName() + "."); } }
final Throwable cause = ex.getReason(); if (cause instanceof UnsupportedEncodingException) { throw new IllegalPropertySetDataException(cause);
/** * Removes the custom properties. */ public void removeCustomProperties() { if (getSectionCount() < 2) { throw new HPSFRuntimeException("Illegal internal format of Document SummaryInformation stream: second section is missing."); } List<Section> l = new LinkedList<>(getSections()); clearSections(); int idx = 0; for (Section s : l) { if (idx++ != 1) { addSection(s); } } }
o += LittleEndianConsts.INT_SIZE; if (sectionCount < 0) { throw new HPSFRuntimeException("Section count " + sectionCount + " is negative.");
throw new HPSFRuntimeException ("Value type of property ID 1 is not VT_I2 but " + type + ".");
/** * @return the section's size in bytes. */ public int getSize() { int size = sectionBytes.size(); if (size > 0) { return size; } try { return calcSize(); } catch (HPSFRuntimeException ex) { throw ex; } catch (Exception ex) { throw new HPSFRuntimeException(ex); } }
/** * <p>Returns the section's size.</p> * * @return the section's size. */ public int getSize() { if (dirty) { try { size = calcSize(); dirty = false; } catch (HPSFRuntimeException ex) { throw ex; } catch (Exception ex) { throw new HPSFRuntimeException(ex); } } return size; }
/** * Returns the value of the numeric property with the specified * ID. If the property is not available, 0 is returned. A * subsequent call to {@link #wasNull} will return * {@code true} to let the caller distinguish that case from * a real property value of 0. * * @param id The property's ID * * @return The property's value */ int getPropertyIntValue(final long id) { final Number i; final Object o = getProperty(id); if (o == null) { return 0; } if (!(o instanceof Long || o instanceof Integer)) { throw new HPSFRuntimeException ("This property is not an integer type, but " + o.getClass().getName() + "."); } i = (Number) o; return i.intValue(); }
/** * <p>Returns the section's size.</p> * * @return the section's size. */ public int getSize() { if (dirty) { try { size = calcSize(); dirty = false; } catch (HPSFRuntimeException ex) { throw ex; } catch (Exception ex) { throw new HPSFRuntimeException(ex); } } return size; }
/** * <p>Returns the value of the numeric property with the specified * ID. If the property is not available, 0 is returned. A * subsequent call to {@link #wasNull} will return * <code>true</code> to let the caller distinguish that case from * a real property value of 0.</p> * * @param id The property's ID * * @return The property's value */ protected int getPropertyIntValue(final long id) { final Number i; final Object o = getProperty(id); if (o == null) return 0; if (!(o instanceof Long || o instanceof Integer)) throw new HPSFRuntimeException ("This property is not an integer type, but " + o.getClass().getName() + "."); i = (Number) o; return i.intValue(); }
/** * <p>Removes the custom properties.</p> */ public void removeCustomProperties() { if (getSectionCount() >= 2) getSections().remove(1); else throw new HPSFRuntimeException("Illegal internal format of Document SummaryInformation stream: second section is missing."); }
/** * <p>Removes the custom properties.</p> */ public void removeCustomProperties() { if (getSectionCount() >= 2) getSections().remove(1); else throw new HPSFRuntimeException("Illegal internal format of Document SummaryInformation stream: second section is missing."); }
/** * <p>Returns the value of the numeric property with the specified * ID. If the property is not available, 0 is returned. A * subsequent call to {@link #wasNull} will return * <code>true</code> to let the caller distinguish that case from * a real property value of 0.</p> * * @param id The property's ID * * @return The property's value */ protected int getPropertyIntValue(final long id) { final Number i; final Object o = getProperty(id); if (o == null) return 0; if (!(o instanceof Long || o instanceof Integer)) throw new HPSFRuntimeException ("This property is not an integer type, but " + o.getClass().getName() + "."); i = (Number) o; return i.intValue(); }
/** * Sets a property. * * @param id The property ID. * @param value The property's value. The value's class must be one of those * supported by HPSF. */ public void setProperty(final int id, final Object value) { if (value instanceof String) { setProperty(id, (String) value); } else if (value instanceof Long) { setProperty(id, ((Long) value).longValue()); } else if (value instanceof Integer) { setProperty(id, ((Integer) value).intValue()); } else if (value instanceof Short) { setProperty(id, ((Short) value).intValue()); } else if (value instanceof Boolean) { setProperty(id, ((Boolean) value).booleanValue()); } else if (value instanceof Date) { setProperty(id, Variant.VT_FILETIME, value); } else { throw new HPSFRuntimeException( "HPSF does not support properties of type " + value.getClass().getName() + "."); } }