/** * Returns the specified date as ISO 8601 format. * * @param date the specified date. * @param format the ISO 8601 format to use. * @return the date formatted using ISO 8601. */ public static String format(long date, ISO8601 format) { return format.format(date); }
/** * Returns the MIME type of the given file based on the global MIME properties * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; }
/** * Suspends encoding of the stream. * * <p>May be helpful if you need to embed a piece of base64-encoded data in a stream. * * @throws java.io.IOException if there's an error flushing * @since 1.5.1 */ public void suspendEncoding() throws IOException { flushBase64(); this.suspendEncoding = true; }
/** * Returns the specified exception as XML. * * @param ex The exception to turn to XML. * @param xml The XML writer. * @param wrap Whether to wrap the XML into an element. * * @throws IOException Only if thrown by the XML writer. */ public static void toXML(Throwable ex, XMLWriter xml, boolean wrap) throws IOException { if (ex instanceof SAXParseException) { asSAXParseExceptionXML((SAXParseException)ex, xml, wrap); } else if (ex instanceof TransformerException) { asTransformerExceptionXML((TransformerException)ex, xml, wrap); } else if (ex instanceof Exception) { asExceptionXML((Exception)ex, xml, wrap); } else if (ex instanceof Error) { asErrorXML((Error)ex, xml, wrap); } }
public String getETag(ContentRequest req) { String etag = buildIndexEtag(req); return etag == null ? null : MD5.hash(etag); }
public boolean isInIndex(File file) { return FileUtils.contains(_contentRoot, file); }
/** * Collect an error reported by an underlying process such as a parser or a transformer without * throwing any exception. * * @param level The level of the exception. * @param exception The exception thrown by the underlying process. * * @throws NullPointerException If either argument is <code>null</code>. */ public final void collectQuietly(Level level, T exception) { this._collected.add(new CollectedError<>(level, exception)); if (this.flag.compareTo(level) <= 0) { this._hasError = true; } }
/** * Returns the source locator as XML. * * <p>Does nothing if the locator is <code>null</code>. * * @param xml the XML writer. * * @throws IOException If thrown by the XML writer. */ @Override public void toXML(XMLWriter xml) throws IOException { xml.openElement("collected"); xml.attribute("level", this._level.toString()); Errors.toXML(this._error, xml, false); xml.closeElement(); }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode(String s) throws IOException { return decode(s, NO_OPTIONS); }
/** * Attempts to decode Base64 data and deserialize a Java * Object within. Returns <tt>null</tt> if there was an error. * * @param encodedObject The Base64 data to decode * @return The decoded and deserialized object * @throws NullPointerException if encodedObject is null * @throws java.io.IOException if there is a general error * @throws ClassNotFoundException if the decoded object is of a * class that cannot be found by the JVM * @since 1.5 */ public static Object decodeToObject(String encodedObject) throws IOException, java.lang.ClassNotFoundException { return decodeToObject(encodedObject, NO_OPTIONS, null); }
/** * Returns the specified exception as XML. * * <p>The XML for a {@link TransformerException} is: * <pre>{@code <exception class="[class]" type="[TransformerException|TransformerConfigException]"> * <message>[message]</message> * <stack-trace>[exception]</stack-trace> * <cause>[cause exception as XML (if any)]</cause> * <location line="[line]" column="[column]" public-id=[public-id]" system-id="[system-id]"/> * </exception> * }</pre> * * @param ex The exception to turn to XML. * @param xml The XML writer. * * @throws IOException Only if thrown by the XML writer. */ public static void toXML(TransformerException ex, XMLWriter xml) throws IOException { asTransformerExceptionXML(ex, xml, true); }
@Override public String toString() { return name().toLowerCase(); } };
@Override public int compareTo(Overlay o) { int compare = this._name.compareTo(o._name); if (compare == 0) { compare = Versions.compare(this._version, o._version); } return compare; }
public boolean isInIndex(File file) { return FileUtils.contains(_contentRoot, file); }
/** * Returns the MIME type of the given file based on the global MIME properties * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; }
/** * Returns the MIME type of the given file based on the global MIME properties * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; }
/** * Returns the MIME type of the given file based on the global MIME properties * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; }
/** * Returns the MIME type of the given file based on the global MIME properties * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; }
/** * Returns the MIME type of the given file based on the global MIME properties. * * <p>Falls back on <code>"application/octet-stream"</code> if the MIME type is unknown. * * @param f The file * @return the corresponding MIME type */ private String getMediaType(File f) { String mime = FileUtils.getMediaType(f); return (mime != null)? mime : "application/octet-stream"; } }