Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * Indicates if the given MIME type is related to XML or not.
     * <p>
     * XML MIME types :
     * </p>
     * <ul>
     * <li>"<tt>text/xml</tt>",</li>
     * <li>"<tt>application/xml</tt>",</li>
     * <li>"<tt>image/svg+xml</tt>",</li>
     * <li>etc</li>
     * </ul>
     * <p>
     * Non-XML MIME types :
     * </p>
     * <ul>
     * <li>"<tt>application/xml-dtd</tt>",</li>
     * <li>"<tt>application/xml-external-parsed-entity</tt>",</li>
     * <li>etc</li>
     * </ul>
     *
     * @param mimeType
     *            The MIME type to test.
     * @return <code>true</code> if the MIME type contains the string "xml" not
     *         followed by "-", <code>false</code> otherwise.
     */
    public static boolean isXMLMimeType(String mimeType) {
        int index = mimeType.indexOf("xml");
        if (index != -1 && (index + 3 < mimeType.length()) ? mimeType.charAt(index + 3) != '-' : true) {
            // "application/xml", "text/xml", "image/svg+xml",
            // "application/xhtml+xml", etc
            // but not "application/xml-dtd",
            // "application/xml-external-parsed-entity" etc
            return true;
        } else {
            return false;
        }
    }
}