List of usage examples for java.lang Character equals
public boolean equals(Object obj)
From source file:superlaskuttaja.logiikka.MerkkiJaMerkkijonoTarkistin.java
/** * Metodi tarkistaa onko argumentti jokin merkeist 0-9, "-" tai " ". * * @param merkki Tarkistettava merkki./* w ww .j a v a2s . c om*/ * @return Tieto onko merkki jokin merkeist 0-9, "-" tai " " vai ei. */ public Boolean onkoMerkkiNumeroValiviivaTaiValilyonti(Character merkki) { for (int i = 0; i < this.numerotValiviivaJaValilyonti.length(); i++) { if (merkki.equals(this.numerotValiviivaJaValilyonti.charAt(i))) { return true; } } return false; }
From source file:com.edgenius.wiki.render.handler.PageIndexHandler.java
public void renderStart(AbstractPage page) { if (page != null && page.getSpace() != null) { String spaceUname = page.getSpace().getUnixName(); List<Page> pages = pageService.getPageTree(spaceUname); indexMap = new TreeMap<String, LinkModel>(new Comparator<String>() { public int compare(String o1, String o2) { Character c1 = Character.toUpperCase(o1.charAt(0)); Character c2 = Character.toUpperCase(o2.charAt(0)); if (c1.equals(c2)) { return o1.compareToIgnoreCase(o2); } else { return c1.compareTo(c2); }/*from w ww.ja v a 2s .c o m*/ } }); indexer = new TreeMap<Character, Integer>(new Comparator<Character>() { public int compare(Character o1, Character o2) { return o1.compareTo(o2); } }); Character indexKey = null; int indexAnchor = 1; for (Page pg : pages) { String title = pg.getTitle(); if (StringUtils.isBlank(title)) { log.error("Blank title page found in {}", spaceUname); continue; } LinkModel link = new LinkModel(); link.setLink(title); link.setType(LinkModel.LINK_TO_VIEW_FLAG); link.setSpaceUname(spaceUname); link.setView(title); indexMap.put(title, link); Character first = Character.toUpperCase(title.charAt(0)); if (!first.equals(indexKey)) { indexKey = first; indexer.put(indexKey, indexAnchor++); } } } }
From source file:piilSource.BarChart.java
public BarChart(final String title, List<List<String>> list, Character meta) { super(title); geneName = title;//ww w.j av a2s .c om metaLabel = (meta.equals('M')) ? "beta" : "expression"; final CategoryDataset dataset = createDataset(list, metaLabel); final JFreeChart chart = createChart(title, dataset, metaLabel); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(600, 300)); setContentPane(chartPanel); 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 ...", chartPanel, "Barplot of the " + metaLabel + " values for all samples - " + title); } }); 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(chartPanel, BorderLayout.CENTER); chartFrame.add(buttonsPanel, BorderLayout.SOUTH); chartFrame.setSize(800, 400); chartFrame.setVisible(true); }
From source file:com.google.flightmap.parsing.faa.nfd.tools.NfdAnalyzer.java
/** * Updates {@code stats} with data record matched by {@link #dataRecordPattern}. *//*from w ww . jav a2 s .c o m*/ private void processDataRecord(final Matcher m, final NfdFileStats s) { ++s.totalRecords; final String type = m.group(1); final String area = m.group(2); final String secCode = m.group(3); // Increment area count Integer count = s.recordsPerArea.get(area); if (count == null) count = 0; count = count + 1; s.recordsPerArea.put(area, count); // Increment section count Character subCode = m.group(0).charAt(5); if (subCode.equals(' ') && (secCode.equals("P") || secCode.equals("H"))) { subCode = m.group(0).charAt(12); } if (!NfdFileStats.isValidCategory(secCode, subCode)) { processUnknownRecord(m.group(0), s); return; } Map<Character, Integer> recordsPerSubsection = s.recordsPerSection.get(secCode); if (recordsPerSubsection == null) { recordsPerSubsection = new TreeMap<Character, Integer>(); s.recordsPerSection.put(secCode, recordsPerSubsection); count = 0; } else { count = recordsPerSubsection.get(subCode); if (count == null) count = 0; } count = count + 1; recordsPerSubsection.put(subCode, count); ++s.dataRecords; }
From source file:org.sufficientlysecure.keychain.ui.adapter.KeySectionedListAdapter.java
@Override protected void onBindSectionViewHolder(KeyHeaderViewHolder holder, Character section) { switch (holder.getItemViewTypeWithoutSections()) { case VIEW_SECTION_TYPE_PUBLIC: { String title = section.equals('?') ? getContext().getString(R.string.user_id_no_name) : String.valueOf(section); holder.bind(title);/*from w ww . j ava 2s .c o m*/ break; } case VIEW_SECTION_TYPE_PRIVATE: { int count = getCount(); String title = getContext().getResources().getQuantityString(R.plurals.n_keys, count, count); holder.bind(title); break; } } }
From source file:com.moviejukebox.tools.FileTools.java
public static void initUnsafeChars() { if (!UNSAFE_CHARS.isEmpty()) { return;/*w w w . ja v a2 s .c o m*/ } // What to do if the user specifies a blank encodeEscapeChar? I guess disable encoding. String encodeEscapeCharString = PropertiesUtil.getProperty("mjb.charset.filenameEncodingEscapeChar", "$"); if (encodeEscapeCharString.length() > 0) { // What to do if the user specifies a >1 character long string? I guess just use the first char. final Character ENCODE_ESCAPE_CHAR = encodeEscapeCharString.charAt(0); String repChars = PropertiesUtil.getProperty("mjb.charset.unsafeFilenameChars", "<>:\"/\\|?*"); for (String repChar : repChars.split("")) { if (repChar.length() > 0) { char ch = repChar.charAt(0); // Don't encode characters that are hex digits // Also, don't encode the escape char -- it is safe by definition! if (!Character.isDigit(ch) && -1 == "AaBbCcDdEeFf".indexOf(ch) && !ENCODE_ESCAPE_CHAR.equals(ch)) { String hex = Integer.toHexString(ch).toUpperCase(); UNSAFE_CHARS.add(new ReplaceEntry(repChar, ENCODE_ESCAPE_CHAR + hex)); } } } } // Parse transliteration map: (source_character [-] transliteration_sequence [,])+ StringTokenizer st = new StringTokenizer(PropertiesUtil.getProperty("mjb.charset.filename.translate", ""), ","); while (st.hasMoreElements()) { final String token = st.nextToken(); String beforeStr = substringBefore(token, "-"); final String character = beforeStr.length() == 1 && ("\t".equals(beforeStr) || " ".equals(beforeStr)) ? beforeStr : trimToNull(beforeStr); if (character == null) { // TODO Error message? continue; } String afterStr = substringAfter(token, "-"); final String translation = afterStr.length() == 1 && ("\t".equals(afterStr) || " ".equals(afterStr)) ? afterStr : trimToNull(afterStr); if (translation == null) { // TODO Error message? // TODO Allow empty transliteration? continue; } UNSAFE_CHARS.add(new ReplaceEntry(character.toUpperCase(), translation.toUpperCase())); UNSAFE_CHARS.add(new ReplaceEntry(character.toLowerCase(), translation.toLowerCase())); } }
From source file:ffx.ui.UIDataConverter.java
/** * Converts the data structure to MolecularAssembly(s). *///from ww w . java 2s . c o m public void convert() { if (timer) { startTimer(); } FFXSystem ffxSystem = null; // Continue if the file was read in successfully. if (conversionFilter.convert()) { ffxSystem = (FFXSystem) conversionFilter.getActiveMolecularSystem(); if (!(conversionFilter instanceof BiojavaFilter)) { Utilities.biochemistry(ffxSystem, conversionFilter.getAtomList()); } conversionFilter.applyAtomProperties(); // Add the system to the multiscale hierarchy. mainPanel.getHierarchy().addSystemNode(ffxSystem); ForceFieldEnergy energy = new ForceFieldEnergy(ffxSystem, conversionFilter.getCoordRestraints()); ffxSystem.setPotential(energy); mainPanel.getHierarchy().setActive(ffxSystem); // Check if there are alternate conformers if (conversionFilter instanceof BiojavaFilter) { BiojavaFilter biojFilter = (BiojavaFilter) conversionFilter; List<Character> altLocs = biojFilter.getAltLocs(); if (altLocs.size() > 1 || altLocs.get(0) != ' ') { StringBuilder altLocString = new StringBuilder("\n Alternate locations found [ "); for (Character c : altLocs) { // Do not report the root conformer. if (c == ' ') { continue; } altLocString.append(String.format("(%s) ", c)); } altLocString.append("]\n"); logger.info(altLocString.toString()); } /** * Alternate conformers may have different chemistry, so they * each need to be their own FFX system. */ for (Character c : altLocs) { if (c.equals(' ') || c.equals('A')) { continue; } FFXSystem newSystem = new FFXSystem(ffxSystem.getFile(), "Alternate Location " + c, ffxSystem.getProperties()); newSystem.setForceField(ffxSystem.getForceField()); biojFilter.setAltID(newSystem, c); biojFilter.clearSegIDs(); if (biojFilter.convert()) { biojFilter.applyAtomProperties(); String fileName = ffxSystem.getFile().getAbsolutePath(); newSystem.setName(FilenameUtils.getBaseName(fileName) + " " + c); mainPanel.getHierarchy().addSystemNode(newSystem); energy = new ForceFieldEnergy(newSystem, biojFilter.getCoordRestraints()); newSystem.setPotential(energy); } } } } else { logger.warning(String.format(" Failed to convert structure %s", dataStructure.toString())); } mainPanel.setCursor(Cursor.getDefaultCursor()); if (timer) { stopTimer(ffxSystem); } }
From source file:ffx.ui.UIFileOpener.java
private void open() { if (timer) {/* w ww . j a v a2s.c o m*/ startTimer(); } FFXSystem ffxSystem = null; // Continue if the file was read in successfully. if (systemFilter.readFile()) { ffxSystem = (FFXSystem) systemFilter.getActiveMolecularSystem(); if (!(systemFilter instanceof PDBFilter)) { Utilities.biochemistry(ffxSystem, systemFilter.getAtomList()); } systemFilter.applyAtomProperties(); // Add the system to the multiscale hierarchy. mainPanel.getHierarchy().addSystemNode(ffxSystem); //ForceFieldEnergy energy = new ForceFieldEnergy(ffxSystem, systemFilter.getCoordRestraints()); ForceFieldEnergy energy; if (nThreads > 0) { energy = new ForceFieldEnergy(ffxSystem, systemFilter.getCoordRestraints(), nThreads); } else { energy = new ForceFieldEnergy(ffxSystem, systemFilter.getCoordRestraints()); } ffxSystem.setPotential(energy); mainPanel.getHierarchy().setActive(ffxSystem); // Check if there are alternate conformers if (systemFilter instanceof PDBFilter) { PDBFilter pdbFilter = (PDBFilter) systemFilter; List<Character> altLocs = pdbFilter.getAltLocs(); if (altLocs.size() > 1 || altLocs.get(0) != ' ') { StringBuilder altLocString = new StringBuilder("\n Alternate locations found [ "); for (Character c : altLocs) { // Do not report the root conformer. if (c == ' ') { continue; } altLocString.append(format("(%s) ", c)); } altLocString.append("]\n"); logger.info(altLocString.toString()); } /** * Alternate conformers may have different chemistry, so they * each need to be their own FFX system. */ for (Character c : altLocs) { if (c.equals(' ') || c.equals('A')) { continue; } FFXSystem newSystem = new FFXSystem(ffxSystem.getFile(), "Alternate Location " + c, ffxSystem.getProperties()); newSystem.setForceField(ffxSystem.getForceField()); pdbFilter.setAltID(newSystem, c); pdbFilter.clearSegIDs(); if (pdbFilter.readFile()) { pdbFilter.applyAtomProperties(); String fileName = ffxSystem.getFile().getAbsolutePath(); newSystem.setName(FilenameUtils.getBaseName(fileName) + " " + c); mainPanel.getHierarchy().addSystemNode(newSystem); //energy = new ForceFieldEnergy(newSystem, pdbFilter.getCoordRestraints()); if (nThreads > 0) { energy = new ForceFieldEnergy(newSystem, systemFilter.getCoordRestraints(), nThreads); } else { energy = new ForceFieldEnergy(newSystem, systemFilter.getCoordRestraints()); } newSystem.setPotential(energy); } } } } else { logger.warning(String.format(" Failed to read file %s", systemFilter.getFile().getName())); } mainPanel.setCursor(Cursor.getDefaultCursor()); if (timer) { stopTimer(ffxSystem); } }
From source file:ffx.potential.utils.PotentialsDataConverter.java
/** * Converts the data structure to MolecularAssembly(s). */// w w w . j a v a 2 s . com @Override public void run() { if (dataStructure == null || dataType.equals(Utilities.DataType.UNK)) { throw new IllegalArgumentException("Object passed was not recognized."); } assemblies = new ArrayList<>(); propertyList = new ArrayList<>(); switch (dataType) { case BIOJAVA: Structure struct = (Structure) dataStructure; String name = struct.getPDBCode(); CompositeConfiguration properties = Keyword.loadProperties(file); MolecularAssembly assembly = new MolecularAssembly(name); assembly.setFile(file); ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties); ForceField forceField = forceFieldFilter.parse(); assembly.setForceField(forceField); BiojavaFilter filter = new BiojavaFilter(struct, assembly, forceField, properties); if (filter.convert()) { filter.applyAtomProperties(); assembly.finalize(true, forceField); ForceFieldEnergy energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints()); assembly.setPotential(energy); assemblies.add(assembly); propertyList.add(properties); List<Character> altLocs = filter.getAltLocs(); if (altLocs.size() > 1 || altLocs.get(0) != ' ') { StringBuilder altLocString = new StringBuilder("\n Alternate locations found [ "); for (Character c : altLocs) { // Do not report the root conformer. if (c == ' ') { continue; } altLocString.append(format("(%s) ", c)); } altLocString.append("]\n"); logger.info(altLocString.toString()); } /** * Alternate conformers may have different chemistry, so * they each need to be their own MolecularAssembly. */ for (Character c : altLocs) { if (c.equals(' ') || c.equals('A')) { continue; } MolecularAssembly newAssembly = new MolecularAssembly(name); newAssembly.setForceField(assembly.getForceField()); filter.setAltID(newAssembly, c); filter.clearSegIDs(); if (filter.convert()) { String fileName = assembly.getFile().getAbsolutePath(); newAssembly.setName(FilenameUtils.getBaseName(fileName) + " " + c); filter.applyAtomProperties(); newAssembly.finalize(true, assembly.getForceField()); energy = new ForceFieldEnergy(newAssembly, filter.getCoordRestraints()); newAssembly.setPotential(energy); assemblies.add(newAssembly); properties.addConfiguration(properties); } } } else { logger.warning(String.format(" Failed to convert structure %s", dataStructure.toString())); } activeAssembly = assembly; activeProperties = properties; break; case UNK: default: throw new IllegalArgumentException("Object passed was not recognized."); } }
From source file:org.apache.zeppelin.jdbc.JDBCInterpreter.java
protected ArrayList<String> splitSqlQueries(String sql) { ArrayList<String> queries = new ArrayList<>(); StringBuilder query = new StringBuilder(); Character character; Boolean antiSlash = false;//from ww w . ja v a 2s . c o m Boolean quoteString = false; Boolean doubleQuoteString = false; for (int item = 0; item < sql.length(); item++) { character = sql.charAt(item); if (character.equals('\\')) { antiSlash = true; } if (character.equals('\'')) { if (antiSlash) { antiSlash = false; } else if (quoteString) { quoteString = false; } else if (!doubleQuoteString) { quoteString = true; } } if (character.equals('"')) { if (antiSlash) { antiSlash = false; } else if (doubleQuoteString) { doubleQuoteString = false; } else if (!quoteString) { doubleQuoteString = true; } } if (character.equals(';') && !antiSlash && !quoteString && !doubleQuoteString) { queries.add(query.toString()); query = new StringBuilder(); } else if (item == sql.length() - 1) { query.append(character); queries.add(query.toString()); } else { query.append(character); } } return queries; }