Java Code Examples for com.sun.tools.javac.util.StringUtils#toLowerCase()

The following examples show how to use com.sun.tools.javac.util.StringUtils#toLowerCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * This checks for the validity of the options used by the user.
 * This works exactly like
 * {@link com.sun.javadoc.Doclet#validOptions(String[][],
 * DocErrorReporter)}. This will validate the options which are shared
 * by our doclets. For example, this method will flag an error using
 * the DocErrorReporter if user has used "-nohelp" and "-helpfile" option
 * together.
 *
 * @param options  options used on the command line.
 * @param reporter used to report errors.
 * @return true if all the options are valid.
 */
public boolean generalValidOptions(String options[][],
        DocErrorReporter reporter) {
    boolean docencodingfound = false;
    String encoding = "";
    for (int oi = 0; oi < options.length; oi++) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-docencoding")) {
            docencodingfound = true;
            if (!checkOutputFileEncoding(os[1], reporter)) {
                return false;
            }
        } else if (opt.equals("-encoding")) {
            encoding = os[1];
        }
    }
    if (!docencodingfound && encoding.length() > 0) {
        if (!checkOutputFileEncoding(encoding, reporter)) {
            return false;
        }
    }
    return true;
}
 
Example 2
/**
 * This checks for the validity of the options used by the user.
 * This works exactly like
 * {@link com.sun.javadoc.Doclet#validOptions(String[][],
 * DocErrorReporter)}. This will validate the options which are shared
 * by our doclets. For example, this method will flag an error using
 * the DocErrorReporter if user has used "-nohelp" and "-helpfile" option
 * together.
 *
 * @param options  options used on the command line.
 * @param reporter used to report errors.
 * @return true if all the options are valid.
 */
public boolean generalValidOptions(String options[][],
        DocErrorReporter reporter) {
    boolean docencodingfound = false;
    String encoding = "";
    for (int oi = 0; oi < options.length; oi++) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-docencoding")) {
            docencodingfound = true;
            if (!checkOutputFileEncoding(os[1], reporter)) {
                return false;
            }
        } else if (opt.equals("-encoding")) {
            encoding = os[1];
        }
    }
    if (!docencodingfound && encoding.length() > 0) {
        if (!checkOutputFileEncoding(encoding, reporter)) {
            return false;
        }
    }
    return true;
}
 
Example 3
/**
 * Add a new <code>SimpleTaglet</code>.  If this tag already exists
 * and the header passed as an argument is null, move tag to the back of the
 * list. If this tag already exists and the header passed as an argument is
 * not null, overwrite previous tag with new one.  Otherwise, add new
 * SimpleTaglet to list.
 * @param tagName the name of this tag
 * @param header the header to output.
 * @param locations the possible locations that this tag
 * can appear in.
 */
public void addNewSimpleCustomTag(String tagName, String header, String locations) {
    if (tagName == null || locations == null) {
        return;
    }
    Taglet tag = customTags.get(tagName);
    locations = StringUtils.toLowerCase(locations);
    if (tag == null || header != null) {
        customTags.remove(tagName);
        customTags.put(tagName, new SimpleTaglet(tagName, header, locations));
        if (locations != null && locations.indexOf('x') == -1) {
            checkTagName(tagName);
        }
    } else {
        //Move to back
        customTags.remove(tagName);
        customTags.put(tagName, tag);
    }
}
 
Example 4
/**
 * Return true if the given Doc should be included
 * in the serialized form.
 *
 * @param doc the Doc object to check for serializability.
 */
private static boolean serialDocInclude(Doc doc) {
    if (doc.isEnum()) {
        return false;
    }
    Tag[] serial = doc.tags("serial");
    if (serial.length > 0) {
        String serialtext = StringUtils.toLowerCase(serial[0].text());
        if (serialtext.indexOf("exclude") >= 0) {
            return false;
        } else if (serialtext.indexOf("include") >= 0) {
            return true;
        }
    }
    return true;
}
 
Example 5
/**
 * Construct a <code>SimpleTaglet</code>.
 * @param tagName the name of this tag
 * @param header the header to output.
 * @param locations the possible locations that this tag
 * can appear in.  The <code>String</code> can contain 'p'
 * for package, 't' for type, 'm' for method, 'c' for constructor
 * and 'f' for field.
 */
public SimpleTaglet(String tagName, String header, String locations) {
    this.tagName = tagName;
    this.header = header;
    locations = StringUtils.toLowerCase(locations);
    if (locations.contains(ALL) && !locations.contains(EXCLUDED)) {
        this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
    } else {
        this.locations = locations;
    }
}
 
Example 6
/**
 * This method should be defined in all those doclets
 * which want to inherit from this Configuration. This method
 * should return the number of arguments to the command line
 * option (including the option name).  For example,
 * -notimestamp is a single-argument option, so this method would
 * return 1.
 *
 * @param option Command line option under consideration.
 * @return number of arguments to option (including the
 * option name). Zero return means option not known.
 * Negative value means error occurred.
 */
public int optionLength(String option) {
    option = StringUtils.toLowerCase(option);
    if (option.equals("-author") ||
        option.equals("-docfilessubdirs") ||
        option.equals("-javafx") ||
        option.equals("-keywords") ||
        option.equals("-linksource") ||
        option.equals("-nocomment") ||
        option.equals("-nodeprecated") ||
        option.equals("-nosince") ||
        option.equals("-notimestamp") ||
        option.equals("-quiet") ||
        option.equals("-xnodate") ||
        option.equals("-version")) {
        return 1;
    } else if (option.equals("-d") ||
               option.equals("-docencoding") ||
               option.equals("-encoding") ||
               option.equals("-excludedocfilessubdir") ||
               option.equals("-link") ||
               option.equals("-sourcetab") ||
               option.equals("-noqualifier") ||
               option.equals("-output") ||
               option.equals("-sourcepath") ||
               option.equals("-tag") ||
               option.equals("-taglet") ||
               option.equals("-tagletpath") ||
               option.equals("-xprofilespath")) {
        return 2;
    } else if (option.equals("-group") ||
               option.equals("-linkoffline")) {
        return 3;
    } else {
        return -1;  // indicate we don't know about it
    }
}
 
Example 7
/**
 * Construct a <code>SimpleTaglet</code>.
 * @param tagName the name of this tag
 * @param header the header to output.
 * @param locations the possible locations that this tag
 * can appear in.  The <code>String</code> can contain 'p'
 * for package, 't' for type, 'm' for method, 'c' for constructor
 * and 'f' for field.
 */
public SimpleTaglet(String tagName, String header, String locations) {
    this.tagName = tagName;
    this.header = header;
    locations = StringUtils.toLowerCase(locations);
    if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) {
        this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
    } else {
        this.locations = locations;
    }
}
 
Example 8
Flag(long flag) {
    this.value = flag;
    this.lowercaseName = StringUtils.toLowerCase(name());
}
 
Example 9
public String getText() {
    return StringUtils.toLowerCase(name());
}
 
Example 10
/**
 * Returns the "length" of a given option. If an option takes no
 * arguments, its length is one. If it takes one argument, it's
 * length is two, and so on. This method is called by JavaDoc to
 * parse the options it does not recognize. It then calls
 * {@link #validOptions(String[][], DocErrorReporter)} to
 * validate them.
 * <b>Note:</b><br>
 * The options arrive as case-sensitive strings. For options that
 * are not case-sensitive, use toLowerCase() on the option string
 * before comparing it.
 *
 * @return number of arguments + 1 for a option. Zero return means
 * option not known.  Negative value means error occurred.
 */
public int optionLength(String option) {
    int result = -1;
    if ((result = super.optionLength(option)) > 0) {
        return result;
    }
    // otherwise look for the options we have added
    option = StringUtils.toLowerCase(option);
    if (option.equals("-nodeprecatedlist") ||
        option.equals("-noindex") ||
        option.equals("-notree") ||
        option.equals("-nohelp") ||
        option.equals("-splitindex") ||
        option.equals("-serialwarn") ||
        option.equals("-use") ||
        option.equals("-nonavbar") ||
        option.equals("-nooverview") ||
        option.equals("-html4") ||
        option.equals("-html5") ||
        option.equals("-xdoclint") ||
        option.startsWith("-xdoclint:") ||
        option.startsWith("-xdoclint/package:") ||
        option.startsWith("--allow-script-in-comments")) {
        return 1;
    } else if (option.equals("-help")) {
        // Uugh: first, this should not be hidden inside optionLength,
        // and second, we should not be writing directly to stdout.
        // But we have no access to a DocErrorReporter, which would
        // allow use of reporter.printNotice
        System.out.println(getText("doclet.usage"));
        return 1;
    } else if (option.equals("-x")) {
        // Uugh: first, this should not be hidden inside optionLength,
        // and second, we should not be writing directly to stdout.
        // But we have no access to a DocErrorReporter, which would
        // allow use of reporter.printNotice
        System.out.println(getText("doclet.X.usage"));
        return 1;
    } else if (option.equals("-footer") ||
               option.equals("-header") ||
               option.equals("-packagesheader") ||
               option.equals("-doctitle") ||
               option.equals("-windowtitle") ||
               option.equals("-top") ||
               option.equals("-bottom") ||
               option.equals("-helpfile") ||
               option.equals("-stylesheetfile") ||
               option.equals("-charset") ||
               option.equals("-overview") ||
               option.equals("-xdocrootparent")) {
        return 2;
    } else {
        return 0;
    }
}
 
Example 11
/**
 * {@inheritDoc}
 */
@Override
public boolean validOptions(String options[][],
        DocErrorReporter reporter) {
    boolean helpfile = false;
    boolean nohelp = false;
    boolean overview = false;
    boolean nooverview = false;
    boolean splitindex = false;
    boolean noindex = false;
    // check shared options
    if (!generalValidOptions(options, reporter)) {
        return false;
    }
    // otherwise look at our options
    for (int oi = 0; oi < options.length; ++oi) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-helpfile")) {
            if (nohelp == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-helpfile", "-nohelp"));
                return false;
            }
            if (helpfile == true) {
                reporter.printError(getText("doclet.Option_reuse",
                    "-helpfile"));
                return false;
            }
            DocFile help = DocFile.createFileForInput(this, os[1]);
            if (!help.exists()) {
                reporter.printError(getText("doclet.File_not_found", os[1]));
                return false;
            }
            helpfile = true;
        } else  if (opt.equals("-nohelp")) {
            if (helpfile == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-nohelp", "-helpfile"));
                return false;
            }
            nohelp = true;
        } else if (opt.equals("-xdocrootparent")) {
            try {
                new URL(os[1]);
            } catch (MalformedURLException e) {
                reporter.printError(getText("doclet.MalformedURL", os[1]));
                return false;
            }
        } else if (opt.equals("-overview")) {
            if (nooverview == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-overview", "-nooverview"));
                return false;
            }
            if (overview == true) {
                reporter.printError(getText("doclet.Option_reuse",
                    "-overview"));
                return false;
            }
            overview = true;
        } else  if (opt.equals("-nooverview")) {
            if (overview == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-nooverview", "-overview"));
                return false;
            }
            nooverview = true;
        } else if (opt.equals("-splitindex")) {
            if (noindex == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-splitindex", "-noindex"));
                return false;
            }
            splitindex = true;
        } else if (opt.equals("-noindex")) {
            if (splitindex == true) {
                reporter.printError(getText("doclet.Option_conflict",
                    "-noindex", "-splitindex"));
                return false;
            }
            noindex = true;
        } else if (opt.startsWith("-xdoclint:")) {
            if (opt.contains("/")) {
                reporter.printError(getText("doclet.Option_doclint_no_qualifiers"));
                return false;
            }
            if (!DocLint.isValidOption(
                    opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) {
                reporter.printError(getText("doclet.Option_doclint_invalid_arg"));
                return false;
            }
        }
    }
    return true;
}
 
Example 12
/**
 * Suppose a piece of documentation has a relative link.  When you copy
 * that documentation to another place such as the index or class-use page,
 * that relative link will no longer work.  We should redirect those links
 * so that they will work again.
 * <p>
 * Here is the algorithm used to fix the link:
 * <p>
 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
 * <p>
 * For example, suppose com.sun.javadoc.RootDoc has this link:
 * {@literal <a href="package-summary.html">The package Page</a> }
 * <p>
 * If this link appeared in the index, we would redirect
 * the link like this:
 *
 * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
 *
 * @param doc the Doc object whose documentation is being written.
 * @param text the text being written.
 *
 * @return the text, with all the relative links redirected to work.
 */
private String redirectRelativeLinks(Doc doc, String text) {
    if (doc == null || shouldNotRedirectRelativeLinks()) {
        return text;
    }

    DocPath redirectPathFromRoot;
    if (doc instanceof ClassDoc) {
        redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
    } else if (doc instanceof MemberDoc) {
        redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
    } else if (doc instanceof PackageDoc) {
        redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
    } else {
        return text;
    }

    //Redirect all relative links.
    int end, begin = StringUtils.indexOfIgnoreCase(text, "<a");
    if(begin >= 0){
        StringBuilder textBuff = new StringBuilder(text);

        while(begin >=0){
            if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
                begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
                continue;
            }

            begin = textBuff.indexOf("=", begin) + 1;
            end = textBuff.indexOf(">", begin +1);
            if(begin == 0){
                //Link has no equal symbol.
                configuration.root.printWarning(
                    doc.position(),
                    configuration.getText("doclet.malformed_html_link_tag", text));
                break;
            }
            if (end == -1) {
                //Break without warning.  This <a> tag is not necessarily malformed.  The text
                //might be missing '>' character because the href has an inline tag.
                break;
            }
            if (textBuff.substring(begin, end).indexOf("\"") != -1){
                begin = textBuff.indexOf("\"", begin) + 1;
                end = textBuff.indexOf("\"", begin +1);
                if (begin == 0 || end == -1){
                    //Link is missing a quote.
                    break;
                }
            }
            String relativeLink = textBuff.substring(begin, end);
            String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink);
            if (!(relativeLinkLowerCase.startsWith("mailto:") ||
                    relativeLinkLowerCase.startsWith("http:") ||
                    relativeLinkLowerCase.startsWith("https:") ||
                    relativeLinkLowerCase.startsWith("file:"))) {
                relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
                    + redirectPathFromRoot.resolve(relativeLink).getPath();
                textBuff.replace(begin, end, relativeLink);
            }
            begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
        }
        return textBuff.toString();
    }
    return text;
}
 
Example 13
/** Is this the name of an archive file? */
private boolean isArchive(File file) {
    String n = StringUtils.toLowerCase(file.getName());
    return fsInfo.isFile(file)
        && (n.endsWith(".jar") || n.endsWith(".zip"));
}
 
Example 14
/**
 * Is this the name of an archive file?
 */
private boolean isArchive(File file) {
    String n = StringUtils.toLowerCase(file.getName());
    return fsInfo.isFile(file)
            && (n.endsWith(".jar") || n.endsWith(".zip"));
}
 
Example 15
/**
 * Suppose a piece of documentation has a relative link.  When you copy
 * that documentation to another place such as the index or class-use page,
 * that relative link will no longer work.  We should redirect those links
 * so that they will work again.
 * <p>
 * Here is the algorithm used to fix the link:
 * <p>
 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
 * <p>
 * For example, suppose com.sun.javadoc.RootDoc has this link:
 * {@literal <a href="package-summary.html">The package Page</a> }
 * <p>
 * If this link appeared in the index, we would redirect
 * the link like this:
 *
 * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
 *
 * @param doc the Doc object whose documentation is being written.
 * @param text the text being written.
 *
 * @return the text, with all the relative links redirected to work.
 */
private String redirectRelativeLinks(Doc doc, String text) {
    if (doc == null || shouldNotRedirectRelativeLinks()) {
        return text;
    }

    DocPath redirectPathFromRoot;
    if (doc instanceof ClassDoc) {
        redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
    } else if (doc instanceof MemberDoc) {
        redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
    } else if (doc instanceof PackageDoc) {
        redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
    } else {
        return text;
    }

    //Redirect all relative links.
    int end, begin = StringUtils.indexOfIgnoreCase(text, "<a");
    if(begin >= 0){
        StringBuilder textBuff = new StringBuilder(text);

        while(begin >=0){
            if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
                begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
                continue;
            }

            begin = textBuff.indexOf("=", begin) + 1;
            end = textBuff.indexOf(">", begin +1);
            if(begin == 0){
                //Link has no equal symbol.
                configuration.root.printWarning(
                    doc.position(),
                    configuration.getText("doclet.malformed_html_link_tag", text));
                break;
            }
            if (end == -1) {
                //Break without warning.  This <a> tag is not necessarily malformed.  The text
                //might be missing '>' character because the href has an inline tag.
                break;
            }
            if (textBuff.substring(begin, end).indexOf("\"") != -1){
                begin = textBuff.indexOf("\"", begin) + 1;
                end = textBuff.indexOf("\"", begin +1);
                if (begin == 0 || end == -1){
                    //Link is missing a quote.
                    break;
                }
            }
            String relativeLink = textBuff.substring(begin, end);
            String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink);
            if (!(relativeLinkLowerCase.startsWith("mailto:") ||
                    relativeLinkLowerCase.startsWith("http:") ||
                    relativeLinkLowerCase.startsWith("https:") ||
                    relativeLinkLowerCase.startsWith("file:"))) {
                relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
                    + redirectPathFromRoot.resolve(relativeLink).getPath();
                textBuff.replace(begin, end, relativeLink);
            }
            begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
        }
        return textBuff.toString();
    }
    return text;
}
 
Example 16
/**
 * Depending upon the command line options provided by the user, set
 * configure the output generation environment.
 *
 * @param options The array of option names and values.
 */
@Override
public void setSpecificDocletOptions(String[][] options) {
    for (int oi = 0; oi < options.length; ++oi) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-footer")) {
            footer = os[1];
        } else if (opt.equals("-header")) {
            header = os[1];
        } else if (opt.equals("-packagesheader")) {
            packagesheader = os[1];
        } else if (opt.equals("-doctitle")) {
            doctitle = os[1];
        } else if (opt.equals("-windowtitle")) {
            windowtitle = os[1].replaceAll("\\<.*?>", "");
        } else if (opt.equals("-top")) {
            top = os[1];
        } else if (opt.equals("-bottom")) {
            bottom = os[1];
        } else if (opt.equals("-helpfile")) {
            helpfile = os[1];
        } else if (opt.equals("-stylesheetfile")) {
            stylesheetfile = os[1];
        } else if (opt.equals("-charset")) {
            charset = os[1];
        } else if (opt.equals("-xdocrootparent")) {
            docrootparent = os[1];
        } else if (opt.equals("-nohelp")) {
            nohelp = true;
        } else if (opt.equals("-splitindex")) {
            splitindex = true;
        } else if (opt.equals("-noindex")) {
            createindex = false;
        } else if (opt.equals("-use")) {
            classuse = true;
        } else if (opt.equals("-notree")) {
            createtree = false;
        } else if (opt.equals("-nodeprecatedlist")) {
            nodeprecatedlist = true;
        } else if (opt.equals("-nonavbar")) {
            nonavbar = true;
        } else if (opt.equals("-nooverview")) {
            nooverview = true;
        } else if (opt.equals("-overview")) {
            overview = true;
        } else if (opt.equals("-xdoclint")) {
            doclintOpts.add(null);
        } else if (opt.startsWith("-xdoclint:")) {
            doclintOpts.add(opt.substring(opt.indexOf(":") + 1));
        }
    }
    if (root.specifiedClasses().length > 0) {
        Map<String,PackageDoc> map = new HashMap<String,PackageDoc>();
        PackageDoc pd;
        ClassDoc[] classes = root.classes();
        for (int i = 0; i < classes.length; i++) {
            pd = classes[i].containingPackage();
            if(! map.containsKey(pd.name())) {
                map.put(pd.name(), pd);
            }
        }
    }
    setCreateOverview();
    setTopFile(root);

    if (root instanceof RootDocImpl) {
        ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames());
    }
}
 
Example 17
/**
 * Suppose a piece of documentation has a relative link.  When you copy
 * that documentation to another place such as the index or class-use page,
 * that relative link will no longer work.  We should redirect those links
 * so that they will work again.
 * <p>
 * Here is the algorithm used to fix the link:
 * <p>
 * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
 * <p>
 * For example, suppose com.sun.javadoc.RootDoc has this link:
 * {@literal <a href="package-summary.html">The package Page</a> }
 * <p>
 * If this link appeared in the index, we would redirect
 * the link like this:
 *
 * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
 *
 * @param doc the Doc object whose documentation is being written.
 * @param text the text being written.
 *
 * @return the text, with all the relative links redirected to work.
 */
private String redirectRelativeLinks(Doc doc, String text) {
    if (doc == null || shouldNotRedirectRelativeLinks()) {
        return text;
    }

    DocPath redirectPathFromRoot;
    if (doc instanceof ClassDoc) {
        redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
    } else if (doc instanceof MemberDoc) {
        redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
    } else if (doc instanceof PackageDoc) {
        redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
    } else {
        return text;
    }

    //Redirect all relative links.
    int end, begin = StringUtils.indexOfIgnoreCase(text, "<a");
    if(begin >= 0){
        StringBuilder textBuff = new StringBuilder(text);

        while(begin >=0){
            if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
                begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
                continue;
            }

            begin = textBuff.indexOf("=", begin) + 1;
            end = textBuff.indexOf(">", begin +1);
            if(begin == 0){
                //Link has no equal symbol.
                configuration.root.printWarning(
                    doc.position(),
                    configuration.getText("doclet.malformed_html_link_tag", text));
                break;
            }
            if (end == -1) {
                //Break without warning.  This <a> tag is not necessarily malformed.  The text
                //might be missing '>' character because the href has an inline tag.
                break;
            }
            if (textBuff.substring(begin, end).indexOf("\"") != -1){
                begin = textBuff.indexOf("\"", begin) + 1;
                end = textBuff.indexOf("\"", begin +1);
                if (begin == 0 || end == -1){
                    //Link is missing a quote.
                    break;
                }
            }
            String relativeLink = textBuff.substring(begin, end);
            String relativeLinkLowerCase = StringUtils.toLowerCase(relativeLink);
            if (!(relativeLinkLowerCase.startsWith("mailto:") ||
                    relativeLinkLowerCase.startsWith("http:") ||
                    relativeLinkLowerCase.startsWith("https:") ||
                    relativeLinkLowerCase.startsWith("file:"))) {
                relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
                    + redirectPathFromRoot.resolve(relativeLink).getPath();
                textBuff.replace(begin, end, relativeLink);
            }
            begin = StringUtils.indexOfIgnoreCase(textBuff.toString(), "<a", begin + 1);
        }
        return textBuff.toString();
    }
    return text;
}
 
Example 18
/**
 * Depending upon the command line options provided by the user, set
 * configure the output generation environment.
 *
 * @param options The array of option names and values.
 */
@Override
public void setSpecificDocletOptions(String[][] options) {
    for (int oi = 0; oi < options.length; ++oi) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-footer")) {
            footer = os[1];
        } else if (opt.equals("-header")) {
            header = os[1];
        } else if (opt.equals("-packagesheader")) {
            packagesheader = os[1];
        } else if (opt.equals("-doctitle")) {
            doctitle = os[1];
        } else if (opt.equals("-windowtitle")) {
            windowtitle = os[1].replaceAll("\\<.*?>", "");
        } else if (opt.equals("-top")) {
            top = os[1];
        } else if (opt.equals("-bottom")) {
            bottom = os[1];
        } else if (opt.equals("-helpfile")) {
            helpfile = os[1];
        } else if (opt.equals("-stylesheetfile")) {
            stylesheetfile = os[1];
        } else if (opt.equals("-charset")) {
            charset = os[1];
        } else if (opt.equals("-xdocrootparent")) {
            docrootparent = os[1];
        } else if (opt.equals("-nohelp")) {
            nohelp = true;
        } else if (opt.equals("-splitindex")) {
            splitindex = true;
        } else if (opt.equals("-noindex")) {
            createindex = false;
        } else if (opt.equals("-use")) {
            classuse = true;
        } else if (opt.equals("-notree")) {
            createtree = false;
        } else if (opt.equals("-nodeprecatedlist")) {
            nodeprecatedlist = true;
        } else if (opt.equals("-nonavbar")) {
            nonavbar = true;
        } else if (opt.equals("-nooverview")) {
            nooverview = true;
        } else if (opt.equals("-overview")) {
            overview = true;
        } else if (opt.equals("-xdoclint")) {
            doclintOpts.add(null);
        } else if (opt.startsWith("-xdoclint:")) {
            doclintOpts.add(opt.substring(opt.indexOf(":") + 1));
        } else if (opt.equals("--allow-script-in-comments")) {
            allowScriptInComments = true;
        }
    }

    if (root.specifiedClasses().length > 0) {
        Map<String,PackageDoc> map = new HashMap<String,PackageDoc>();
        PackageDoc pd;
        ClassDoc[] classes = root.classes();
        for (int i = 0; i < classes.length; i++) {
            pd = classes[i].containingPackage();
            if(! map.containsKey(pd.name())) {
                map.put(pd.name(), pd);
            }
        }
    }
    setCreateOverview();
    setTopFile(root);

    if (root instanceof RootDocImpl) {
        ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames());
        JavaScriptScanner jss = ((RootDocImpl) root).initJavaScriptScanner(isAllowScriptInComments());
        if (jss != null) {
            // In a more object-oriented world, this would be done by methods on the Option objects.
            // Note that -windowtitle silently removes any and all HTML elements, and so does not need
            // to be handled here.
            checkJavaScript(jss, "-header", header);
            checkJavaScript(jss, "-footer", footer);
            checkJavaScript(jss, "-top", top);
            checkJavaScript(jss, "-bottom", bottom);
            checkJavaScript(jss, "-doctitle", doctitle);
            checkJavaScript(jss, "-packagesheader", packagesheader);
        }
    }
}
 
Example 19
/**
 * Depending upon the command line options provided by the user, set
 * configure the output generation environment.
 *
 * @param options The array of option names and values.
 */
@Override
public void setSpecificDocletOptions(String[][] options) {
    for (int oi = 0; oi < options.length; ++oi) {
        String[] os = options[oi];
        String opt = StringUtils.toLowerCase(os[0]);
        if (opt.equals("-footer")) {
            footer = os[1];
        } else if (opt.equals("-header")) {
            header = os[1];
        } else if (opt.equals("-packagesheader")) {
            packagesheader = os[1];
        } else if (opt.equals("-doctitle")) {
            doctitle = os[1];
        } else if (opt.equals("-windowtitle")) {
            windowtitle = os[1].replaceAll("\\<.*?>", "");
        } else if (opt.equals("-top")) {
            top = os[1];
        } else if (opt.equals("-bottom")) {
            bottom = os[1];
        } else if (opt.equals("-helpfile")) {
            helpfile = os[1];
        } else if (opt.equals("-stylesheetfile")) {
            stylesheetfile = os[1];
        } else if (opt.equals("-charset")) {
            charset = os[1];
        } else if (opt.equals("-xdocrootparent")) {
            docrootparent = os[1];
        } else if (opt.equals("-nohelp")) {
            nohelp = true;
        } else if (opt.equals("-splitindex")) {
            splitindex = true;
        } else if (opt.equals("-noindex")) {
            createindex = false;
        } else if (opt.equals("-use")) {
            classuse = true;
        } else if (opt.equals("-notree")) {
            createtree = false;
        } else if (opt.equals("-nodeprecatedlist")) {
            nodeprecatedlist = true;
        } else if (opt.equals("-nonavbar")) {
            nonavbar = true;
        } else if (opt.equals("-nooverview")) {
            nooverview = true;
        } else if (opt.equals("-overview")) {
            overview = true;
        } else if (opt.equals("-xdoclint")) {
            doclintOpts.add(null);
        } else if (opt.startsWith("-xdoclint:")) {
            doclintOpts.add(opt.substring(opt.indexOf(":") + 1));
        }
    }
    if (root.specifiedClasses().length > 0) {
        Map<String,PackageDoc> map = new HashMap<String,PackageDoc>();
        PackageDoc pd;
        ClassDoc[] classes = root.classes();
        for (int i = 0; i < classes.length; i++) {
            pd = classes[i].containingPackage();
            if(! map.containsKey(pd.name())) {
                map.put(pd.name(), pd);
            }
        }
    }
    setCreateOverview();
    setTopFile(root);

    if (root instanceof RootDocImpl) {
        ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames());
    }
}
 
Example 20
String optName() { return StringUtils.toLowerCase(name()); }