List of usage examples for com.google.common.base CaseFormat UPPER_CAMEL
CaseFormat UPPER_CAMEL
To view the source code for com.google.common.base CaseFormat UPPER_CAMEL.
Click Source Link
From source file:com.tactfactory.harmony.generator.BundleGenerator.java
/** * Generate bundle's generator./*www .j a v a2s . c o m*/ * @param bundleOwnerName Owner name * @param bundleName Bundle name * @param bundleNameSpace Bundle namespace */ private void generateTemplate(final String bundleOwnerName, final String bundleName, final String bundleNameSpace) { final String tplPath = this.getAdapter().getTemplateBundleTemplatePath() + "/TemplateGenerator.java"; final String genPath = this.getAdapter().getTemplateBundlePath(bundleOwnerName, bundleNameSpace, bundleName) + "/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, bundleName) + "Generator.java"; this.makeSource(tplPath, genPath, false); }
From source file:jp.atr.unr.pf.roboearth.RoboEarthInterface.java
/** * Sends a 'semantic query' to the RoboEarth DB to search for an environment model * // w w w . jav a2 s . c o m * @param roomNumber Environment for which to search (currently: room number) * @return Array of URL strings pointing to the recipe specifications * @throws IOException * @throws ParserConfigurationException * @throws SAXException */ public static String[] searchEnvironmentMapsFor(String[][] roomQuery) throws IOException, ParserConfigurationException, SAXException { String q = "SELECT source FROM CONTEXT source\n" + "{A} kr:describedInMap {Z} ,\n"; ArrayList<String> constr = new ArrayList<String>(); ArrayList<String> where = new ArrayList<String>(); char idx = 'A'; for (String[] constraint : roomQuery) { if (idx != 'A') { constr.add("{" + idx + "} kr:properPhysicalParts {" + (char) (idx - 1) + "}"); } String var = constraint[0].split(":")[1]; var = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, var); var = "V" + var; // avoid problems with reserved words like 'label' constr.add("{" + idx + "} " + constraint[0] + " {" + var + "}"); where.add(var + " LIKE \"" + constraint[1] + "\""); idx++; } q += Joiner.on(" , \n").join(constr); q += "\nWHERE\n" + Joiner.on("\nAND ").join(where); q += "\nUSING NAMESPACE\n" + "re=<http://www.roboearth.org/kb/roboearth.owl#>,\n" + "rdfs=<http://www.w3.org/2000/01/rdf-schema#>,\n" + "kr=<http://ias.cs.tum.edu/kb/knowrob.owl#> "; //CommunicationVisApplet.visualizeCommunication("Requesting map from RoboEarth..." + q, "", "pr2.jpg", "roboearth.png"); String res; REConnectionHadoop conn = new REConnectionHadoop(API_KEY); res = conn.queryEnvironmentDB(q); res = res.replace("\\n", "").replace("\\t", ""); res = res.substring(1, res.length() - 1); ArrayList<String> env_urls = new ArrayList<String>(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(false); factory.newSAXParser().parse(new InputSource(new StringReader(res)), new SparqlReader(env_urls)); // String map_names = ""; ArrayList<String> maps = new ArrayList<String>(); for (String url : env_urls) { maps.add(getFilenameFromURL(url)); // map_names += getFilenameFromURL(url) + ", "; } //CommunicationVisApplet.visualizeCommunication(null, "Received environment maps "+ map_names, "pr2.jpg", "roboearth.png"); return maps.toArray(new String[0]); }
From source file:org.intellij.erlang.refactor.introduce.ErlangExtractFunctionHandler.java
private static void perform(final Editor editor, List<ErlangExpression> selection) { final ErlangExpression first = ContainerUtil.getFirstItem(selection); final ErlangFunction function = PsiTreeUtil.getParentOfType(first, ErlangFunction.class); final ErlangExpression last = selection.get(selection.size() - 1); assert first != null; assert function != null; assert last != null; Pair<List<ErlangNamedElement>, List<ErlangNamedElement>> analyze = analyze(selection); final Project project = first.getProject(); List<ErlangNamedElement> inParams = analyze.first; List<ErlangNamedElement> outParams = analyze.second; String shorten = ErlangRefactoringUtil.shorten(last, "extracted"); String name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, shorten); ErlangExtractFunctionDialog dialog = new ErlangExtractFunctionDialog(project, name, inParams); if (ApplicationManager.getApplication().isUnitTestMode() || dialog.showAndGet()) { final String functionName = dialog.getFunctionName(); final String bindings = bindings(outParams); final String bindingsEx = StringUtil.isEmpty(bindings) ? bindings : ",\n" + bindings; final String bindingsS = StringUtil.isEmpty(bindings) ? bindings : bindings + " = "; final String signature = generateSignature(functionName, inParams); final String functionText = signature + " ->\n" + StringUtil.join(selection, new Function<ErlangExpression, String>() { @Override//from www . j a v a 2 s. c o m public String fun(ErlangExpression erlangExpression) { return erlangExpression.getText(); } }, ",\n") + bindingsEx + "."; try { final PsiFile file = first.getContainingFile(); new WriteCommandAction(editor.getProject(), "Extract function", file) { @Override protected void run(Result result) throws Throwable { ErlangFunction newFunction = ErlangElementFactory.createFunctionFromText(project, functionText); PsiElement functionParent = function.getParent(); PsiElement added = functionParent.addAfter(newFunction, function); functionParent.addBefore(newLine(), added); functionParent.addAfter(newLine(), function); PsiElement parent = first.getParent(); parent.addBefore( ErlangElementFactory.createExpressionFromText(getProject(), bindingsS + signature), first); parent.deleteChildRange(first, last); } private PsiElement newLine() { return ErlangElementFactory.createLeafFromText(project, "\n"); } }.execute(); } catch (Throwable throwable) { LOGGER.warn(throwable); } } }
From source file:datamine.storage.idl.generator.java.InterfaceGenerator.java
public static String getDerivedInterfaceName(String tableName) { return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName)) .append("DerivedValueInterface").toString(); }
From source file:com.puppycrawl.tools.checkstyle.checks.javadoc.ExpectedParseTreeGenerator.java
public String walk(ParseTree t, String parentObjectName) { final String className = t.getClass().getSimpleName(); String id = null;//from ww w. j a v a 2 s . c o m if (t instanceof TerminalNode) { final TerminalNodeImpl terminal = (TerminalNodeImpl) t; final int type = terminal.symbol.getType(); String tokenType = ""; if (type == -1) { tokenType = "EOF"; } else { tokenType = JavadocUtils.getTokenName(type); } String text = terminal.getText(); if ("\n".equals(text)) { text = "\\n"; } else if ("\t".equals(text)) { text = "\\t"; } else { text = text.replace("\"", "\\\""); } final int number = getVariableCounter(tokenType); id = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tokenType.toLowerCase()) + number; System.out.println(" CommonToken " + id + " = new CommonToken(JavadocTokenTypes." + tokenType + ", \"" + text + "\");"); } else { int number = getVariableCounter(className); id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, className) + number++; System.out.println( " " + className + " " + id + " = new " + className + "(" + parentObjectName + ", 0);"); final int n = t.getChildCount(); for (int i = 0; i < n; i++) { final String childId = walk(t.getChild(i), id); System.out.println(" " + id + ".addChild(" + childId + ");"); } } return id; }
From source file:org.intellij.erlang.refactoring.introduce.ErlangExtractFunctionHandler.java
private static void perform(@NotNull Editor editor, @NotNull List<ErlangExpression> selection) { final ErlangExpression first = ContainerUtil.getFirstItem(selection); final ErlangFunction function = PsiTreeUtil.getParentOfType(first, ErlangFunction.class); final ErlangExpression last = selection.get(selection.size() - 1); assert first != null; assert function != null; assert last != null; Pair<List<ErlangNamedElement>, List<ErlangNamedElement>> analyze = analyze(selection); final Project project = first.getProject(); List<ErlangNamedElement> inParams = analyze.first; List<ErlangNamedElement> outParams = analyze.second; String shorten = ErlangRefactoringUtil.shorten(last, "extracted"); String name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, shorten); ErlangExtractFunctionDialog dialog = new ErlangExtractFunctionDialog(project, name, inParams); if (ApplicationManager.getApplication().isUnitTestMode() || dialog.showAndGet()) { String functionName = dialog.getFunctionName(); String bindings = bindings(outParams); String bindingsEx = StringUtil.isEmpty(bindings) ? bindings : ",\n" + bindings; final String bindingsS = StringUtil.isEmpty(bindings) ? bindings : bindings + " = "; final String signature = generateSignature(functionName, inParams); final String functionText = signature + " ->\n" + StringUtil.join(selection, PsiElement::getText, ",\n") + bindingsEx + "."; try {/*from w w w . j a v a 2s . c o m*/ PsiFile file = first.getContainingFile(); new WriteCommandAction(editor.getProject(), "Extract function", file) { @Override protected void run(@NotNull Result result) throws Throwable { ErlangFunction newFunction = ErlangElementFactory.createFunctionFromText(project, functionText); PsiElement functionParent = function.getParent(); PsiElement added = functionParent.addAfter(newFunction, function); functionParent.addBefore(newLine(), added); functionParent.addAfter(newLine(), function); PsiElement parent = first.getParent(); parent.addBefore( ErlangElementFactory.createExpressionFromText(getProject(), bindingsS + signature), first); parent.deleteChildRange(first, last); } private PsiElement newLine() { return ErlangElementFactory.createLeafFromText(project, "\n"); } }.execute(); } catch (Throwable throwable) { LOGGER.warn(throwable); } } Disposer.dispose(dialog.getDisposable()); }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.RedSettingProposals.java
private String toCanonicalName(final String settingName) { switch (target) { case GENERAL: final Iterable<String> upperCased = transform(Splitter.on(' ').split(settingName), new Function<String, String>() { @Override// ww w.j a va2 s.c om public String apply(final String elem) { return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, elem); } }); return Joiner.on(' ').join(upperCased); case TEST_CASE: case KEYWORD: final char firstLetter = settingName.charAt(1); return settingName.replaceAll("\\[" + firstLetter, "[" + Character.toUpperCase(firstLetter)); default: throw new IllegalStateException("Unknown target value: " + target); } }
From source file:org.dllearner.cli.DocumentationGenerator.java
private String getComponentConfigString(Class<?> component, Class<?> category) { // heading + anchor StringBuilder sb = new StringBuilder(); String klass = component.getName(); String header = "component: " + klass; String description = ""; String catString = "component"; String usage = null;/*from ww w . java 2s . c o m*/ // some information about the component if (Component.class.isAssignableFrom(component)) { Class<? extends Component> ccomp = (Class<? extends Component>) component; header = "component: " + AnnComponentManager.getName(ccomp) + " (" + klass + ") v" + AnnComponentManager.getVersion(ccomp); description = AnnComponentManager.getDescription(ccomp); catString = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, category.getSimpleName()); ComponentAnn catAnn = category.getAnnotation(ComponentAnn.class); if (catAnn != null) { catString = catAnn.shortName(); } for (Entry<Class, String> entry : varNameMapping.entrySet()) { Class cls = entry.getKey(); if (cls.isAssignableFrom(component)) { catString = entry.getValue(); } } usage = "conf file usage: " + catString + ".type = \"" + AnnComponentManager.getShortName(ccomp) + "\"\n"; } else { ComponentAnn ann = component.getAnnotation(ComponentAnn.class); if (ann != null) { header = "component: " + ann.name() + " (" + klass + ") v" + ann.version(); } description = ann.description(); if (component.equals(GlobalDoc.class)) { catString = ""; usage = ""; } else { catString = "cli"; usage = "conf file usage: " + catString + ".type = \"" + klass + "\"\n"; } } header += "\n" + Strings.repeat("=", header.length()) + "\n"; sb.append(header); if (description.length() > 0) { sb.append(description + "\n"); } sb.append("\n"); sb.append(usage + "\n"); optionsTable(sb, component, catString); return sb.toString(); }
From source file:datamine.storage.idl.generator.java.InterfaceGenerator.java
public static String getDefaultDerivedClassName(String tableName) { return new StringBuilder().append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, tableName)) .append("DefaultDerivedValues").toString(); }
From source file:cfa.vo.interop.SAMPProxy.java
private static String objectName(Method method) { String name = method.getName().replaceFirst("^get|^set|^add", ""); name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name); return name;/*from w w w . j a va 2 s .c o m*/ }