src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java

changeset 1740
ce4f0769b4b2
parent 1648
a03c4a86ea2b
child 1747
df4f44800923
     1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Tue May 14 10:14:53 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Tue May 14 10:14:53 2013 -0700
     1.3 @@ -27,6 +27,8 @@
     1.4  
     1.5  import java.io.*;
     1.6  import java.util.*;
     1.7 +import java.util.regex.Matcher;
     1.8 +import java.util.regex.Pattern;
     1.9  
    1.10  import com.sun.javadoc.*;
    1.11  import com.sun.tools.javac.sym.Profiles;
    1.12 @@ -825,6 +827,82 @@
    1.13          }
    1.14      }
    1.15  
    1.16 +    public abstract Content getContentForResource();
    1.17 +
    1.18 +    /**
    1.19 +     * Get the configuration string as a content.
    1.20 +     *
    1.21 +     * @param key the key to look for in the configuration file
    1.22 +     * @return a content tree for the text
    1.23 +     */
    1.24 +    public Content getResource(String key) {
    1.25 +        Content c = getContentForResource();
    1.26 +        c.addContent(getText(key));
    1.27 +        return c;
    1.28 +    }
    1.29 +
    1.30 +    /**
    1.31 +     * Get the configuration string as a content.
    1.32 +     *
    1.33 +     * @param key the key to look for in the configuration file
    1.34 +     * @param o   string or content argument added to configuration text
    1.35 +     * @return a content tree for the text
    1.36 +     */
    1.37 +    public Content getResource(String key, Object o) {
    1.38 +        return getResource(key, o, null, null);
    1.39 +    }
    1.40 +
    1.41 +    /**
    1.42 +     * Get the configuration string as a content.
    1.43 +     *
    1.44 +     * @param key the key to look for in the configuration file
    1.45 +     * @param o   string or content argument added to configuration text
    1.46 +     * @return a content tree for the text
    1.47 +     */
    1.48 +    public Content getResource(String key, Object o1, Object o2) {
    1.49 +        return getResource(key, o1, o2, null);
    1.50 +    }
    1.51 +
    1.52 +    /**
    1.53 +     * Get the configuration string as a content.
    1.54 +     *
    1.55 +     * @param key the key to look for in the configuration file
    1.56 +     * @param o1  string or content argument added to configuration text
    1.57 +     * @param o2  string or content argument added to configuration text
    1.58 +     * @return a content tree for the text
    1.59 +     */
    1.60 +    public Content getResource(String key, Object o0, Object o1, Object o2) {
    1.61 +        Content c = getContentForResource();
    1.62 +        Pattern p = Pattern.compile("\\{([012])\\}");
    1.63 +        String text = getText(key);
    1.64 +        Matcher m = p.matcher(text);
    1.65 +        int start = 0;
    1.66 +        while (m.find(start)) {
    1.67 +            c.addContent(text.substring(start, m.start()));
    1.68 +
    1.69 +            Object o = null;
    1.70 +            switch (m.group(1).charAt(0)) {
    1.71 +                case '0': o = o0; break;
    1.72 +                case '1': o = o1; break;
    1.73 +                case '2': o = o2; break;
    1.74 +            }
    1.75 +
    1.76 +            if (o == null) {
    1.77 +                c.addContent("{" + m.group(1) + "}");
    1.78 +            } else if (o instanceof String) {
    1.79 +                c.addContent((String) o);
    1.80 +            } else if (o instanceof Content) {
    1.81 +                c.addContent((Content) o);
    1.82 +            }
    1.83 +
    1.84 +            start = m.end();
    1.85 +        }
    1.86 +
    1.87 +        c.addContent(text.substring(start));
    1.88 +        return c;
    1.89 +    }
    1.90 +
    1.91 +
    1.92      /**
    1.93       * Return true if the ClassDoc element is getting documented, depending upon
    1.94       * -nodeprecated option and the deprecation information. Return true if

mercurial