List of usage examples for java.lang Character equals
public boolean equals(Object obj)
From source file:org.gatein.wcm.util.FileAux.java
public static String changeLinks(String doc, Map<Long, Long> mUploads) { if (doc == null || doc.length() == 0) { return null; }/*ww w . j a v a 2 s .c om*/ int length = doc.length(); int i = 0; int startToken = -1; int finishToken = -1; boolean finish = false; boolean modified = false; StringBuilder output = new StringBuilder(); while (!finish) { boolean found = false; Character ch = doc.charAt(i); // Checks if there is a pattern under present position if (ch.equals('r') && ((i + 1) < length) && doc.charAt(i + 1) == 's' && ((i + 2) < length) && doc.charAt(i + 2) == '/' && ((i + 3) < length) && doc.charAt(i + 3) == 'u' && ((i + 4) < length) && doc.charAt(i + 4) == '/') { // Search end of token boolean numbers = true; startToken = i; finishToken = i + 5; while (numbers) { if (finishToken < length && doc.charAt(finishToken) >= '0' && doc.charAt(finishToken) <= '9') { finishToken++; } else { numbers = false; } } if (finishToken < length) { String token = doc.substring(startToken, finishToken); int index = -1; try { index = new Integer(token.substring(5, token.length())); } catch (Exception e) { // Not a number } if (index > -1) { Long newIndex = mUploads.get(new Long(index)); if (newIndex != null) { output.append("rs/u/" + newIndex); found = true; modified = true; i = finishToken - 1; // To read end quotes } } } } if (!found) { output.append(ch); } i++; if (i >= length) { finish = true; } } if (modified) { return output.toString(); } else { return null; } }
From source file:com.change_vision.astah.extension.plugin.csharpreverse.reverser.DoxygenXmlParser.java
/** * ???????????????????<br/>//from w w w . ja va 2s. c o m * * () _(?)<br/> * : _1<br/> * . _8 * * @param str * * @return ??? */ private static String convertString(String str) { StringBuffer sb = new StringBuffer(); for (Character ch : str.toCharArray()) { if (ch.equals(':')) { sb.append("_1"); } else if (ch.equals('.')) { sb.append("_8"); } else if (Character.isUpperCase(ch)) { sb.append("_" + Character.toLowerCase(ch)); } else { sb.append(ch); } } return sb.toString(); }
From source file:org.openbravo.module.taxreportlauncher.Utility.OBTL_Utility.java
/** * Formats the input string/*from w ww .j a va 2 s. c o m*/ * * @param str * String to be formated. Null means repeat fillChar length-1 times * @param length * final length of the returned string * @param fillChar * character used to fill the returned string. (Null is equivalent to ' ') * @param toRight * if true, it aligns to the right (" 81"); else to the left ("81 ") * @param paramName * parameter's name. Useful only for giving context in case of error * @return a formated string * @throws OBException */ private static String internalFormat(String str, int length, Character fillChar, boolean toRight, String paramName) throws OBException { if (length <= 0) { // Impossible to format the string to a length less or equal to 0 throw new OBTL_Exception("@OBTL_InvalidLengthTitle@" + paramName, "@OBTL_Length0@"); } else { if (fillChar == null || fillChar.equals("")) fillChar = ' '; if (str == null) { StringBuffer sb = new StringBuffer(length); for (int i = 0; i < length; i++) sb.append(fillChar); return sb.toString(); } else { if (str.length() <= length) { StringBuffer sb = new StringBuffer(length); if (toRight) { for (int i = 0; i < length - str.length(); i++) { sb.append(fillChar); } sb.append(str); } else { sb.append(str); for (int i = 0; i < length - str.length(); i++) { sb.append(fillChar); } } return sb.toString(); } else { // Impossible to format string. str length is greater than the expected final length throw new OBTL_Exception("@OBTL_InvalidLengthTitle@" + paramName, str + "@OBTL_GreaterFinalLengthMessage@" + length); } } } }
From source file:es.ua.impact.utils.EditDistanceAligner.java
static public int editDistance(List<Character> s, List<Character> t, int[] alignment) { int m = s.size(); // length of s int n = t.size(); // length of t short[][] table = new short[m + 1][n + 1]; short[] d = null; short[] p = null; if (n == 0) { return m; } else if (m == 0) { return n; }/* www. j a v a 2 s .c o m*/ short[] swap; // placeholder to assist in swapping p and d // indexes into strings s and t short i; // iterates through s short j; // iterates through t Character s_i = null; // ith object of s short cost; // cost p = table[0]; for (j = 0; j <= n; j++) { p[j] = j; } for (i = 1; i <= m; i++) { d = table[i]; s_i = s.get(i - 1); d[0] = i; Character t_j = null; // ith object of s for (j = 1; j <= n; j++) { t_j = t.get(j - 1); cost = s_i.equals(t_j) ? (short) 0 : (short) 1; // minimum of cell to the left+1, to the top+1, diagonally left // and up +cost d[j] = minimum(d[j - 1] + 1, p[j] + 1, p[j - 1] + cost); } // copy current distance counts to 'previous row' distance counts p = d; } if (alignment != null) { i = (short) s.size(); j = (short) t.size(); if (s.get(i - 1).equals(t.get(j - 1))) alignment[i - 1] = j - 1; else alignment[i - 1] = -1; while (j > 1) { if (table[i - 1][j - 1] < table[i - 1][j]) { if (table[i - 1][j - 1] < table[i][j - 1]) { i--; j--; if (s.get(i - 1).equals(t.get(j - 1))) alignment[i - 1] = j - 1; else alignment[i - 1] = -1; } else { j--; /*if(s.get(i-1).equals(t.get(j-1))) alignment[i-1]=j-1; else alignment[i-1]=-1;*/ } } else { if (table[i - 1][j] < table[i][j - 1]) { i--; if (s.get(i - 1).equals(t.get(j - 1))) alignment[i - 1] = j - 1; else alignment[i - 1] = -1; } else { j--; /*if(s.get(i-1).equals(t.get(j-1))){ alignment[i-1]=j-1; } else alignment[i-1]=-1;*/ } } } } if (false) { for (j = 0; j < t.size() + 1; j++) { for (i = 0; i < s.size(); i++) { System.out.print(table[i][j]); System.out.print("\t"); } System.out.println(table[i][j]); } } // our last action in the above loop was to switch d and p, so p now // actually has the most recent cost counts return p[n]; }
From source file:com.wms.utils.DataUtil.java
/** * Check an object is active// w w w. j a v a 2 s .c o m * * @param status status of object * @param isDelete isdetete status of object * @return */ public static boolean isActive(Character status, Character isDelete) { return Objects.equals(status, '1') && (isDelete == null || isDelete.equals('0')); }
From source file:org.apache.spark.sql.parser.SemanticAnalyzer.java
@SuppressWarnings("nls") public static String unescapeSQLString(String b) { Character enclosure = null; // Some of the strings can be passed in as unicode. For example, the // delimiter can be passed in as \002 - So, we first check if the // string is a unicode number, else go back to the old behavior StringBuilder sb = new StringBuilder(b.length()); for (int i = 0; i < b.length(); i++) { char currentChar = b.charAt(i); if (enclosure == null) { if (currentChar == '\'' || b.charAt(i) == '\"') { enclosure = currentChar; }//from w ww .j a v a 2 s. c om // ignore all other chars outside the enclosure continue; } if (enclosure.equals(currentChar)) { enclosure = null; continue; } if (currentChar == '\\' && (i + 6 < b.length()) && b.charAt(i + 1) == 'u') { int code = 0; int base = i + 2; for (int j = 0; j < 4; j++) { int digit = Character.digit(b.charAt(j + base), 16); code += digit * multiplier[j]; } sb.append((char) code); i += 5; continue; } if (currentChar == '\\' && (i + 4 < b.length())) { char i1 = b.charAt(i + 1); char i2 = b.charAt(i + 2); char i3 = b.charAt(i + 3); if ((i1 >= '0' && i1 <= '1') && (i2 >= '0' && i2 <= '7') && (i3 >= '0' && i3 <= '7')) { byte bVal = (byte) ((i3 - '0') + ((i2 - '0') * 8) + ((i1 - '0') * 8 * 8)); byte[] bValArr = new byte[1]; bValArr[0] = bVal; String tmp = new String(bValArr); sb.append(tmp); i += 3; continue; } } if (currentChar == '\\' && (i + 2 < b.length())) { char n = b.charAt(i + 1); switch (n) { case '0': sb.append("\0"); break; case '\'': sb.append("'"); break; case '"': sb.append("\""); break; case 'b': sb.append("\b"); break; case 'n': sb.append("\n"); break; case 'r': sb.append("\r"); break; case 't': sb.append("\t"); break; case 'Z': sb.append("\u001A"); break; case '\\': sb.append("\\"); break; // The following 2 lines are exactly what MySQL does TODO: why do we do this? case '%': sb.append("\\%"); break; case '_': sb.append("\\_"); break; default: sb.append(n); } i++; } else { sb.append(currentChar); } } return sb.toString(); }
From source file:piilSource.Histogram.java
public Histogram(final String s, List<List<String>> list, Character meta) { super(s);/*www . j a v a 2 s. c o m*/ metaLabel = (meta.equals('M')) ? "beta" : "expression"; histogramPanel = createDemoPanel(s, list, metaLabel); histogramPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(histogramPanel); exportButton = new JButton("Export to image"); exportButton.setPreferredSize(new Dimension(150, 30)); closeButton = new JButton("Close"); closeButton.setPreferredSize(new Dimension(150, 30)); buttonsPanel = new JPanel(); buttonsPanel.setLayout(new FlowLayout()); buttonsPanel.setBackground(Color.WHITE); buttonsPanel.add(exportButton); buttonsPanel.add(closeButton); exportButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent bc) { ExportDialog export = new ExportDialog(); export.showExportDialog(chartFrame, "Export view as ...", histogramPanel, "Histogram of the " + metaLabel + " values for all samples - " + s); } }); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { chartFrame.dispose(); } }); chartFrame = new JFrame(); chartFrame.setLayout(new BorderLayout()); chartFrame.setSize(400, 100); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension dim = tk.getScreenSize(); int xPos = (dim.width / 2) - (chartFrame.getWidth() / 2); int yPos = (dim.height / 2) - (chartFrame.getHeight() / 2); chartFrame.setLocation(xPos, yPos); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); chartFrame.add(histogramPanel, BorderLayout.CENTER); chartFrame.add(buttonsPanel, BorderLayout.SOUTH); chartFrame.setSize(800, 400); chartFrame.setVisible(true); }
From source file:nl.kpmg.lcm.server.documentation.MethodDocumentator.java
private String buildFullPath(String basePath, String path) { StringBuilder fullPath = new StringBuilder(); fullPath.append(basePath);/*from w ww. j a va 2 s. co m*/ Character slash = '/'; if ((basePath.length() == 0 || !slash.equals(basePath.charAt(basePath.length() - 1))) && (path.length() == 0 || !slash.equals(path.charAt(0)))) { fullPath.append(slash); } fullPath.append(path); return fullPath.toString(); }
From source file:superlaskuttaja.logiikka.MerkkiJaMerkkijonoTarkistin.java
/** * Metodi tarkistaa onko argumentti kirjain A-Z. * * @param merkki Tarkistettava merkki./*from w w w .j a va2 s. co m*/ * @return Tieto onko merkki kirjain vai ei. */ public Boolean onkoMerkkiKirjainAZ(Character merkki) { for (int i = 0; i < this.isotAakkosetAZ.length(); i++) { if (merkki.equals(this.isotAakkosetAZ.charAt(i))) { return true; } } return false; }
From source file:com.edgenius.wiki.render.handler.PageIndexHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) throws RenderHandlerException { if (indexer == null) { log.warn("Unable to find valid page for index"); throw new RenderHandlerException("Unable to find valid page for index"); }//from ww w . j a va2s .co m List<String> filters = getFilterList(values != null ? StringUtils.trimToNull(values.get("filter")) : null); List<String> filtersOut = getFilterList( values != null ? StringUtils.trimToNull(values.get("filterout")) : null); //temporary cache for indexer after filter out TreeMap<Character, Integer> indexerFiltered = new TreeMap<Character, Integer>(); List<RenderPiece> listPieces = new ArrayList<RenderPiece>(); //render each character list Character indexKey = null; boolean requireEndOfMacroPageIndexList = false; for (Entry<String, LinkModel> entry : indexMap.entrySet()) { String title = entry.getKey(); if (filters.size() > 0) { boolean out = false; for (String filter : filters) { if (!FilenameUtils.wildcardMatch(title.toLowerCase(), filter.toLowerCase())) { out = true; break; } } if (out) continue; } if (filtersOut.size() > 0) { boolean out = false; for (String filterOut : filtersOut) { if (FilenameUtils.wildcardMatch(title.toLowerCase(), filterOut.toLowerCase())) { out = true; break; } } if (out) continue; } Character first = Character.toUpperCase(title.charAt(0)); if (!first.equals(indexKey)) { if (requireEndOfMacroPageIndexList) { listPieces.add(new TextModel("</div>")); //macroPageIndexList } Integer anchorIdx = indexer.get(first); indexKey = first; if (anchorIdx != null) { indexerFiltered.put(first, anchorIdx); listPieces.add(new TextModel(new StringBuilder().append( "<div class=\"macroPageIndexList\"><div class=\"macroPageIndexKey\" id=\"pageindexanchor-") .append(anchorIdx).append("\">").append(first).toString())); requireEndOfMacroPageIndexList = true; //up image line to return top if (RenderContext.RENDER_TARGET_PAGE.equals(renderContext.getRenderTarget())) { LinkModel back = new LinkModel(); back.setAnchor("pageindexanchor-0"); back.setAid("Go back index character list"); back.setView(renderContext.buildSkinImageTag("render/link/up.png", NameConstants.AID, SharedConstants.NO_RENDER_TAG)); listPieces.add(back); } listPieces.add(new TextModel("</div>"));//macroPageIndexKey } else { log.error("Unable to page indexer for {}", indexKey); } } listPieces.add(new TextModel("<div class=\"macroPageIndexLink\">")); LinkModel link = entry.getValue(); link.setLinkTagStr(renderContext.buildURL(link)); listPieces.add(link); listPieces.add(new TextModel("</div>"));//macroPageIndexLink } if (requireEndOfMacroPageIndexList) { listPieces.add(new TextModel("</div>")); //macroPageIndexList } //render sum of characters - although it display before page list, however, as filter may hide some characters, so display later than //other List<RenderPiece> pieces = new ArrayList<RenderPiece>(); StringBuffer sbuf = new StringBuffer("<div aid=\"pageindex\" class=\"macroPageIndex ") .append(WikiConstants.mceNonEditable).append("\""); if (values != null && values.size() > 0) { sbuf.append(" wajax=\"") .append(RichTagUtil.buildWajaxAttributeString(this.getClass().getName(), values)).append("\" "); } sbuf.append("><div id=\"pageindexanchor-0\" class=\"macroPageIndexKeys\">"); pieces.add(new TextModel(sbuf.toString())); for (Entry<Character, Integer> entry : indexerFiltered.entrySet()) { LinkModel anchor = new LinkModel(); anchor.setView(entry.getKey().toString()); anchor.setAnchor("pageindexanchor-" + entry.getValue()); anchor.setLinkTagStr(renderContext.buildURL(anchor)); pieces.add(anchor); } pieces.add(new TextModel("</div>")); //macroPageIndexKeys pieces.addAll(listPieces); pieces.add(new TextModel("</div>")); //macroPageIndex return pieces; }