com.sun.tools.javac.util.StringUtils Java Examples
The following examples show how to use
com.sun.tools.javac.util.StringUtils.
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
Source File: StringUtilsTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Locale.setDefault(new Locale("tr", "TR")); //verify the properties of the default locale: assertEquals("\u0131", "I".toLowerCase()); assertEquals("\u0130", "i".toUpperCase()); //verify the StringUtils.toLowerCase/toUpperCase do what they should: assertEquals("i", StringUtils.toLowerCase("I")); assertEquals("I", StringUtils.toUpperCase("i")); //verify StringUtils.caseInsensitiveIndexOf works: assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); }
Example #2
Source File: Configuration.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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
Source File: Checker.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public Void visitEntity(EntityTree tree, Void ignore) { checkAllowsText(tree); markEnclosingTag(Flag.HAS_TEXT); String name = tree.getName().toString(); if (name.startsWith("#")) { int v = StringUtils.toLowerCase(name).startsWith("#x") ? Integer.parseInt(name.substring(2), 16) : Integer.parseInt(name.substring(1), 10); if (!Entity.isValid(v)) { env.messages.error(HTML, tree, "dc.entity.invalid", name); } } else if (!Entity.isValid(name)) { env.messages.error(HTML, tree, "dc.entity.invalid", name); } return null; }
Example #4
Source File: SerializedFormBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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.contains("exclude")) { return false; } else if (serialtext.contains("include")) { return true; } } return true; }
Example #5
Source File: StringUtilsTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Locale.setDefault(new Locale("tr", "TR")); //verify the properties of the default locale: assertEquals("\u0131", "I".toLowerCase()); assertEquals("\u0130", "i".toUpperCase()); //verify the StringUtils.toLowerCase/toUpperCase do what they should: assertEquals("i", StringUtils.toLowerCase("I")); assertEquals("I", StringUtils.toUpperCase("i")); //verify StringUtils.caseInsensitiveIndexOf works: assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); }
Example #6
Source File: Checker.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public Void visitEntity(EntityTree tree, Void ignore) { checkAllowsText(tree); markEnclosingTag(Flag.HAS_TEXT); String name = tree.getName().toString(); if (name.startsWith("#")) { int v = StringUtils.toLowerCase(name).startsWith("#x") ? Integer.parseInt(name.substring(2), 16) : Integer.parseInt(name.substring(1), 10); if (!Entity.isValid(v)) { env.messages.error(HTML, tree, "dc.entity.invalid", name); } } else if (!Entity.isValid(name)) { env.messages.error(HTML, tree, "dc.entity.invalid", name); } return null; }
Example #7
Source File: Util.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Given a ClassDoc, return the name of its type (Class, Interface, etc.). * * @param cd the ClassDoc to check. * @param lowerCaseOnly true if you want the name returned in lower case. * If false, the first letter of the name is capitalized. * @return */ public static String getTypeName(Configuration config, ClassDoc cd, boolean lowerCaseOnly) { String typeName = ""; if (cd.isOrdinaryClass()) { typeName = "doclet.Class"; } else if (cd.isInterface()) { typeName = "doclet.Interface"; } else if (cd.isException()) { typeName = "doclet.Exception"; } else if (cd.isError()) { typeName = "doclet.Error"; } else if (cd.isAnnotationType()) { typeName = "doclet.AnnotationType"; } else if (cd.isEnum()) { typeName = "doclet.Enum"; } return config.getText( lowerCaseOnly ? StringUtils.toLowerCase(typeName) : typeName); }
Example #8
Source File: SerializedFormBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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 #9
Source File: Configuration.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * 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 #10
Source File: StringUtilsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Locale.setDefault(new Locale("tr", "TR")); //verify the properties of the default locale: assertEquals("\u0131", "I".toLowerCase()); assertEquals("\u0130", "i".toUpperCase()); //verify the StringUtils.toLowerCase/toUpperCase do what they should: assertEquals("i", StringUtils.toLowerCase("I")); assertEquals("I", StringUtils.toUpperCase("i")); //verify StringUtils.caseInsensitiveIndexOf works: assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); }
Example #11
Source File: StringUtilsTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Locale.setDefault(new Locale("tr", "TR")); //verify the properties of the default locale: assertEquals("\u0131", "I".toLowerCase()); assertEquals("\u0130", "i".toUpperCase()); //verify the StringUtils.toLowerCase/toUpperCase do what they should: assertEquals("i", StringUtils.toLowerCase("I")); assertEquals("I", StringUtils.toUpperCase("i")); //verify StringUtils.caseInsensitiveIndexOf works: assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor")); assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11)); assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor")); }
Example #12
Source File: TagletManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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 #13
Source File: Configuration.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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 #14
Source File: SerializedFormBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * 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 #15
Source File: SerializedFormBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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 #16
Source File: SerializedFormBuilder.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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 #17
Source File: Configuration.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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 #18
Source File: Start.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
boolean matches(List<String> names, String arg) { for (String name : names) { if (StringUtils.toLowerCase(name).equals(StringUtils.toLowerCase(arg))) return true; } return false; }
Example #19
Source File: PubApi.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public Set<Modifier> parseModifiers(String modifiers) { if (modifiers == null) return Collections.emptySet(); return Stream.of(modifiers.split(" ")) .map(String::trim) .map(StringUtils::toUpperCase) .filter(s -> !s.isEmpty()) .map(Modifier::valueOf) .collect(Collectors.toSet()); }
Example #20
Source File: SimpleTaglet.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #21
Source File: HtmlDocletWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static String removeNonInlineHtmlTags(String text) { final int len = text.length(); int startPos = 0; // start of text to copy int lessThanPos = text.indexOf('<'); // position of latest '<' if (lessThanPos < 0) { return text; } StringBuilder result = new StringBuilder(); main: while (lessThanPos != -1) { int currPos = lessThanPos + 1; if (currPos == len) break; char ch = text.charAt(currPos); if (ch == '/') { if (++currPos == len) break; ch = text.charAt(currPos); } int tagPos = currPos; while (isHtmlTagLetterOrDigit(ch)) { if (++currPos == len) break main; ch = text.charAt(currPos); } if (ch == '>' && blockTags.contains(StringUtils.toLowerCase(text.substring(tagPos, currPos)))) { result.append(text, startPos, lessThanPos); startPos = currPos + 1; } lessThanPos = text.indexOf('<', currPos); } result.append(text.substring(startPos)); return result.toString(); }
Example #22
Source File: SimpleTaglet.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 #23
Source File: TypeAnnotationWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override void writeDetails(Instruction instr) { String indent = space(2); // get from Options? int pc = instr.getPC(); List<Note> notes = pcMap.get(pc); if (notes != null) { for (Note n: notes) { print(indent); print("@"); annotationWriter.write(n.anno, false, true); print(", "); println(StringUtils.toLowerCase(n.kind.toString())); } } }
Example #24
Source File: Messages.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void setOption(String arg) throws IllegalArgumentException { if (arg.equals(Stats.OPT)) { stats.setEnabled(true); return; } int sep = arg.indexOf("/"); if (sep > 0) { Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1))); setOption(arg.substring(0, sep), ak); } else { setOption(arg, null); } }
Example #25
Source File: Configuration.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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 #26
Source File: Configuration.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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); switch (option) { case "-author": case "-docfilessubdirs": case "-javafx": case "-keywords": case "-linksource": case "-nocomment": case "-nodeprecated": case "-nosince": case "-notimestamp": case "-quiet": case "-xnodate": case "-version": case "-xdaccessinternalapi": return 1; case "-d": case "-docencoding": case "-encoding": case "-excludedocfilessubdir": case "-link": case "-sourcetab": case "-noqualifier": case "-output": case "-sourcepath": case "-tag": case "-taglet": case "-tagletpath": return 2; case "-group": case "-linkoffline": return 3; default: return -1; // indicate we don't know about it } }
Example #27
Source File: Messages.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void setOptions(String opts) { if (opts == null) setOption(ALL, Env.AccessKind.PRIVATE); else { for (String opt: opts.split(",")) setOption(StringUtils.toLowerCase(opt.trim())); } }
Example #28
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Incorporation error: mismatch between inferred type and given bound. */ void reportInstError(UndetVar uv, InferenceBound ib) { reportInferenceError( String.format("inferred.do.not.conform.to.%s.bounds", StringUtils.toLowerCase(ib.name())), uv.getInst(), uv.getBounds(ib)); }
Example #29
Source File: TagletManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Initialize lowercase version of standard Javadoc tags. */ private void initStandardTagsLowercase() { Iterator<String> it = standardTags.iterator(); while (it.hasNext()) { standardTagsLowercase.add(StringUtils.toLowerCase(it.next())); } }
Example #30
Source File: Messages.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static boolean isValidOptions(String opts) { for (String opt: opts.split(",")) { if (!isValidOption(StringUtils.toLowerCase(opt.trim()))) return false; } return true; }