List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:edu.cornell.med.icb.goby.modes.TestDiscoverSequenceVariantsMode.java
private static void writeAlignmentEntries(char toBase, AlignmentWriter writer, int numAlignmentEntries, int readIndex, int referencePosition, int positionStart) throws IOException { for (int j = 0; j < numAlignmentEntries; j++) { final Alignments.AlignmentEntry.Builder builder = Alignments.AlignmentEntry.newBuilder(); builder.setQueryIndex(readIndex++); builder.setTargetIndex(0);/* w w w . j av a 2 s.c o m*/ builder.setQueryLength(50); builder.setPosition(referencePosition++ + positionStart); builder.setMatchingReverseStrand(j % 2 == 0); // builder.setMatchingReverseStrand(false); builder.setScore(50); builder.setNumberOfIndels(0); builder.setQueryAlignedLength(50); int multiplicity = 1; builder.setMultiplicity(multiplicity); builder.setTargetAlignedLength(50); Alignments.SequenceVariation.Builder varBuilder = Alignments.SequenceVariation.newBuilder(); varBuilder.setFrom("A"); varBuilder.setTo(Character.toString(toBase)); varBuilder.setToQuality(ByteString.copyFrom(new byte[] { 40 })); varBuilder.setPosition(25); varBuilder.setReadIndex(25); // System.out.printf("%s j=%d var A/G at %d%n", basenames[basenameIndex], j, 25 + referencePosition + positionStart - 1); builder.addSequenceVariations(varBuilder); final Alignments.AlignmentEntry entry = builder.build(); writer.appendEntry(entry); } }
From source file:org.jopac2.jbal.iso2709.Unimarc.java
/** * Simply split codes and put/*from w w w . j ava 2 s .com*/ * 101 x$a$b$c$d$e$f$g$h$i$j * Indicators * Indicator 1: Translation indicator * 0 Item is in the original language(s) of the work * 1 Item is a translation of the original work or an intermediate work * 2 Item contains translations other than translated summaries * Indicator 2: blank (not defined) * $a Language of Text, Soundtrack etc. * $b Language of Intermediate Text when Item is Not Translated from Original. * $c Language of Original Work * $d Language of Summary * $e Language of Contents Page * $f Language of Title Page if Different from Text * $g Language of Title Proper if Not First Language of Text, Soundtrack, etc. * $h Language of Libretto, etc. * $i Language of Accompanying Material (Other than Summaries, Abstracts or Librettos) * $j Language of Subtitles * @throws JOpac2Exception */ public void setLanguage(String language) throws JOpac2Exception { if (language == null || language.length() == 0) return; String[] l = language.split(" "); removeTags("101"); Tag t = new Tag("101", ' ', ' '); if (l.length > 1) t.setModifier1('1'); // if more than 1 lang assume is translated else t.setModifier1('0'); for (int i = 0; i < l.length; i++) { String f = Character.toString((char) (97 + i)); // starting form 'a' t.addField(new Field(f, l[i])); } addTag(t); }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
protected void splitTweets() { String text = mEditText != null ? parseString(mEditText.getText()) : null; String[] chunks = text.split("\\s+"); String replyTo = null;//from www .ja v a 2 s . co m if (chunks.length >= 1) { final String firstWord = chunks[0]; final char firstCharacter = firstWord.charAt(0); if (Character.toString(firstCharacter).equals("@")) { replyTo = firstWord; } } String currentPart = ""; tweetParts = new ArrayList<String>(); for (final String word : chunks) { int checkLength = 120; if (tweetParts.size() > 1 && replyTo != null) { checkLength = 120 - replyTo.length() + 1; } if (currentPart.length() + word.length() + 1 > checkLength) { if (tweetParts.size() >= 1 && replyTo != null) { tweetParts.add(replyTo + " " + currentPart); } else { tweetParts.add(currentPart); } currentPart = ""; } if (currentPart.equals("")) { currentPart = word; } else { currentPart = currentPart + " " + word; } } if (!currentPart.equals("")) { if (tweetParts.size() >= 1 && replyTo != null) { tweetParts.add(replyTo + " " + currentPart); } else { tweetParts.add(currentPart); } } if (tweetParts.size() >= 1) { for (int i = tweetParts.size(); i > 0; i--) { String part = tweetParts.get(i - 1); String postString = part + " (" + getString(R.string.split_part) + " " + Integer.toString(i) + ")"; final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false); final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null; mService.updateStatus(mAccountIds, postString, attach_location ? mRecentLocation : null, mImageUri, mInReplyToStatusId, has_media && mIsPossiblySensitive, mIsPhotoAttached && !mIsImageAttached); } setResult(Activity.RESULT_OK); finish(); } }
From source file:edu.emory.cci.aiw.i2b2etl.ksb.I2b2KnowledgeSourceBackend.java
public String getLanguagePropertyValueSetDelimiter() { return Character.toString(languagePropertyValueSetDelimiter); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java
public void generatesearchFOVs() { // Copied from generateFOVs() ArrayList<FOV> searchfovs = new ArrayList<FOV>(); //Use the display table to ArrayList<FOV> preexisting = new ArrayList<FOV>(tableModel_.getData()); searchFOVtableModel_.clearAllData(); tableModel_.clearAllData();/*from www . j a va 2 s. c o m*/ //Clear pre-existing FOV table? Not sure yet, so comment out //tableModel_.clearAllData(); for (int cols = 0; cols < pp_.getPlateColumns(); cols++) { ArrayList<Boolean> temp = pmdp_.wellsSelected_.get(cols); for (int rows = 0; rows < pp_.getPlateRows(); rows++) { if (temp.get(rows)) { //Always do spiral for now... String wellString = Character.toString((char) (65 + rows)) + Integer.toString(cols + 1); //Max # of times to search = #of FOVs desired * #to try before giving up searchfovs = generateSpiral( parent_.getPrefind_NoOfAttempts() * parent_.getPrefind_NoOfFOVToFind(), wellString); //searchfovs = generateSpiral(Integer.parseInt(FOVToFindField.getText())*(Integer.parseInt(attemptsField.getText())),wellString); for (FOV fov : searchfovs) { //Do we need this part? if (preexisting.contains(fov)) { fov.setGroup(preexisting.get(preexisting.indexOf(fov)).getGroup()); } else { fov.setGroup(groupDescField.getText()); } searchFOVtableModel_.addRow(fov); } //Can ignore the Z stuff? //doZStackGeneration(getZStackParams()); } } } }
From source file:com.yek.keyboard.keyboards.views.AnyKeyboardViewBase.java
private CharSequence adjustLabelToShiftState(AnyKeyboard.AnyKey key) { CharSequence label = key.label; if (mKeyboard.isShifted()) { if (!TextUtils.isEmpty(key.shiftedKeyLabel)) { return key.shiftedKeyLabel; } else if (label != null && label.length() == 1) { label = Character.toString((char) key.getCodeAtIndex(0, mKeyDetector.isKeyShifted(key))); }// ww w .j a va2s. co m //remembering for next time if (key.isShiftCodesAlways()) key.shiftedKeyLabel = label; } return label; }
From source file:com.diversityarrays.dalclient.DalUtil.java
static public String[] splitCsvLine(String line, char columnSeparator, char quoteCharacter, String[] headings) { // Short circuit if no quote characters in the line if (line.indexOf(quoteCharacter) < 0) { return line.split(Pattern.quote(Character.toString(columnSeparator)), -1); }// www. j a v a 2s . co m List<String> result = headings == null ? new ArrayList<String>() : new ArrayList<String>(headings.length); int lineLength = line.length(); StringBuilder field = new StringBuilder(); SplitState state = SplitState.LOOKING_FOR_SEPARATOR; for (int i = 0; i < lineLength; ++i) { char ch = line.charAt(i); if (state == SplitState.LOOKING_FOR_SEPARATOR) { if (ch == columnSeparator) { result.add(field.toString()); field.setLength(0); } else { if (field.length() == 0 && ch == quoteCharacter) { // Only quote characters after the column separator are recognized // as the beginning of a quoted string... state = SplitState.IN_QUOTE; } else { field.append(ch); } } } else if (state == SplitState.IN_QUOTE) { if (ch == quoteCharacter) { state = SplitState.LOOKING_FOR_SECOND; } else { field.append(ch); } } else if (state == SplitState.LOOKING_FOR_SECOND) { if (ch == quoteCharacter) { // Doubled quote - we'll keep it and keep looking... field.append(quoteCharacter); state = SplitState.IN_QUOTE; } else if (ch == columnSeparator) { // Actually, we've reached the end of the field ! result.add(field.toString()); field.setLength(0); state = SplitState.LOOKING_FOR_SEPARATOR; } } } result.add(field.toString()); return result.toArray(new String[result.size()]); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java
private CharSequence adjustLabelToShiftState(AnyKey key) { CharSequence label = key.label; if (mKeyboard.isShifted()) { if (!TextUtils.isEmpty(key.shiftedKeyLabel)) { return key.shiftedKeyLabel; } else if (label != null && label.length() == 1) { label = Character.toString((char) key.getCodeAtIndex(0, mKeyDetector.isKeyShifted(key))); }/*from w w w .j av a2 s.c o m*/ //remembering for next time if (key.isShiftCodesAlways()) key.shiftedKeyLabel = label; } return label; }
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.por.PORFileReader.java
private void decodeData(BufferedReader reader) throws IOException { List<String[]> dataTableList = new ArrayList<String[]>(); List<String[]> dateFormatList = new ArrayList<String[]>(); int[] variableTypeFinal = new int[varQnty]; // create a File object to save the tab-delimited data file File tabDelimitedDataFile = File.createTempFile("tempTabfile.", ".tab"); smd.getFileInformation().put("tabDelimitedDataFileLocation", tabDelimitedDataFile.getAbsolutePath()); FileOutputStream fileOutTab = null; PrintWriter pwout = null;//from w w w . j ava2s . c o m try { fileOutTab = new FileOutputStream(tabDelimitedDataFile); pwout = new PrintWriter(new OutputStreamWriter(fileOutTab, "utf8"), true); variableFormatTypeList = new String[varQnty]; for (int i = 0; i < varQnty; i++) { variableFormatTypeList[i] = SPSSConstants.FORMAT_CATEGORY_TABLE .get(printFormatTable.get(variableNameList.get(i))); formatCategoryTable.put(variableNameList.get(i), variableFormatTypeList[i]); } // contents (variable) checker concering decimals Arrays.fill(variableTypeFinal, 0); // raw-case counter int j = 0; // case // use while instead for because the number of cases (observations) is usually unknown FBLOCK: while (true) { j++; // case(row)-wise storage object; to be updated after each row-reading String[] casewiseRecord = new String[varQnty]; String[] caseWiseDateFormat = new String[varQnty]; String[] casewiseRecordForTabFile = new String[varQnty]; // warning: the above object is later shallow-copied to the // data object for calculating a UNF value/summary statistics // for (int i = 0; i < varQnty; i++) { // check the type of this variable boolean isStringType = variableTypeTable.get(variableNameList.get(i)) > 0 ? true : false; if (isStringType) { // String case variableTypeFinal[i] = -1; StringBuilder sb_StringLengthBase30 = new StringBuilder(""); int stringLengthBase10 = 0; String buffer = ""; char[] tmp = new char[1]; int nint; while ((nint = reader.read(tmp)) > 0) { buffer = Character.toString(tmp[0]); if (buffer.equals("/")) { break; } else if (buffer.equals("Z")) { if (i == 0) { // the reader has passed the last case; subtract 1 from the j counter caseQnty = j - 1; break FBLOCK; } } else { sb_StringLengthBase30.append(buffer); } } if (nint == 0) { // no more data to be read (reached the eof) caseQnty = j - 1; break FBLOCK; } dbgLog.finer( j + "-th case " + i + "=th var:datum length=" + sb_StringLengthBase30.toString()); // this length value should be a positive integer Matcher mtr = pattern4positiveInteger.matcher(sb_StringLengthBase30.toString()); if (mtr.matches()) { stringLengthBase10 = Integer.valueOf(sb_StringLengthBase30.toString(), 30); } else { // reading error case throw new IOException("reading F(data) section: string: length is not integer"); } // read this string-variable's contents after "/" char[] char_datumString = new char[stringLengthBase10]; reader.read(char_datumString); String datum = new String(char_datumString); casewiseRecord[i] = datum; casewiseRecordForTabFile[i] = "\"" + datum.replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\""; // end of string case } else { // numeric case StringBuilder sb_datumNumericBase30 = new StringBuilder(""); boolean isMissingValue = false; String datum = null; String datumForTabFile = null; String datumDateFormat = null; String buffer = ""; char[] tmp = new char[1]; int nint; while ((nint = reader.read(tmp)) > 0) { sb_datumNumericBase30.append(buffer); buffer = Character.toString(tmp[0]); if (buffer.equals("/")) { break; } else if (buffer.equals("Z")) { if (i == 0) { // the reader has passed the last case // subtract 1 from the j counter dbgLog.fine("Z-mark was detected"); caseQnty = j - 1; break FBLOCK; } } else if (buffer.equals("*")) { // '*' is the first character of the system missing value datumForTabFile = MissingValueForTextDataFile; datum = null; isMissingValue = true; // read next char '.' as part of the missing value reader.read(tmp); buffer = Character.toString(tmp[0]); break; } } if (nint == 0) { // no more data to be read; reached the eof caseQnty = j - 1; break FBLOCK; } // follow-up process for non-missing-values if (!isMissingValue) { // decode a numeric datum as String String datumNumericBase30 = sb_datumNumericBase30.toString(); Matcher matcher = pattern4Integer.matcher(datumNumericBase30); if (matcher.matches()) { // integer case datum = Long.valueOf(datumNumericBase30, 30).toString(); } else { // double case datum = doubleNumberFormatter.format(base30Tobase10Conversion(datumNumericBase30)); } // now check format (if date or time) String variableFormatType = variableFormatTypeList[i]; if (variableFormatType.equals("date")) { variableTypeFinal[i] = -1; long dateDatum = Long.parseLong(datum) * 1000L - SPSS_DATE_OFFSET; datum = sdf_ymd.format(new Date(dateDatum)); datumDateFormat = sdf_ymd.toPattern(); } else if (variableFormatType.equals("time")) { variableTypeFinal[i] = -1; int formatDecimalPointPosition = formatDecimalPointPositionList.get(i); if (printFormatTable.get(variableNameList.get(i)).equals("DTIME")) { if (datum.indexOf(".") < 0) { long dateDatum = Long.parseLong(datum) * 1000L - SPSS_DATE_BIAS; datum = sdf_dhms.format(new Date(dateDatum)); // don't save date format for dtime } else { // decimal point included String[] timeData = datum.split("\\."); long dateDatum = Long.parseLong(timeData[0]) * 1000L - SPSS_DATE_BIAS; StringBuilder sb_time = new StringBuilder( sdf_dhms.format(new Date(dateDatum))); if (formatDecimalPointPosition > 0) { sb_time.append( "." + timeData[1].substring(0, formatDecimalPointPosition)); } datum = sb_time.toString(); // don't save date format for dtime } } else if (printFormatTable.get(variableNameList.get(i)).equals("DATETIME")) { if (datum.indexOf(".") < 0) { long dateDatum = Long.parseLong(datum) * 1000L - SPSS_DATE_OFFSET; datum = sdf_ymdhms.format(new Date(dateDatum)); datumDateFormat = sdf_ymdhms.toPattern(); } else { // decimal point included String[] timeData = datum.split("\\."); long dateDatum = Long.parseLong(timeData[0]) * 1000L - SPSS_DATE_OFFSET; StringBuilder sb_time = new StringBuilder( sdf_ymdhms.format(new Date(dateDatum))); if (formatDecimalPointPosition > 0) { sb_time.append( "." + timeData[1].substring(0, formatDecimalPointPosition)); } datum = sb_time.toString(); datumDateFormat = sdf_ymdhms.toPattern() + (formatDecimalPointPosition > 0 ? ".S" : ""); } } else if (printFormatTable.get(variableNameList.get(i)).equals("TIME")) { if (datum.indexOf(".") < 0) { long dateDatum = Long.parseLong(datum) * 1000L; datum = sdf_hms.format(new Date(dateDatum)); datumDateFormat = sdf_hms.toPattern(); } else { // decimal point included String[] timeData = datum.split("\\."); long dateDatum = Long.parseLong(timeData[0]) * 1000L; StringBuilder sb_time = new StringBuilder( sdf_hms.format(new Date(dateDatum))); if (formatDecimalPointPosition > 0) { sb_time.append( "." + timeData[1].substring(0, formatDecimalPointPosition)); } datum = sb_time.toString(); datumDateFormat = sdf_hms.toPattern() + (formatDecimalPointPosition > 0 ? ".S" : ""); } } } else if (variableFormatType.equals("other")) { if (printFormatTable.get(variableNameList.get(i)).equals("WKDAY")) { // day of week variableTypeFinal[i] = -1; datum = SPSSConstants.WEEKDAY_LIST.get(Integer.valueOf(datum) - 1); } else if (printFormatTable.get(variableNameList.get(i)).equals("MONTH")) { // month variableTypeFinal[i] = -1; datum = SPSSConstants.MONTH_LIST.get(Integer.valueOf(datum) - 1); } } // since value is not missing, set both values to be the same datumForTabFile = datum; // decimal-point check (variable is integer or not) if (variableTypeFinal[i] == 0) { if (datum.indexOf(".") >= 0) { variableTypeFinal[i] = 1; decimalVariableSet.add(i); } } } casewiseRecord[i] = datum; caseWiseDateFormat[i] = datumDateFormat; casewiseRecordForTabFile[i] = datumForTabFile; } // end: if: string vs numeric variable } // end:for-loop-i (variable-wise loop) // print the i-th case; use casewiseRecord to dump the current case to the tab-delimited file pwout.println(StringUtils.join(casewiseRecordForTabFile, "\t")); // store the current case-holder object to the data object for later operations such as UNF/summary statistics dataTableList.add(casewiseRecord); dateFormatList.add(caseWiseDateFormat); } // end: while-block } finally { // close the print writer if (pwout != null) { pwout.close(); } } smd.setDecimalVariables(decimalVariableSet); smd.getFileInformation().put("caseQnty", caseQnty); // store data in column(variable)-wise for calculating variable-wise statistics Object[][] dataTable2 = new Object[varQnty][caseQnty]; String[][] dateFormat = new String[varQnty][caseQnty]; for (int jl = 0; jl < caseQnty; jl++) { for (int jk = 0; jk < varQnty; jk++) { dataTable2[jk][jl] = dataTableList.get(jl)[jk]; dateFormat[jk][jl] = dateFormatList.get(jl)[jk]; } } String[] unfValues = new String[varQnty]; for (int k = 0; k < varQnty; k++) { int variableTypeNumer = variableTypeFinal[k]; unfValues[k] = getUNF(dataTable2[k], dateFormat[k], variableTypeNumer, k); } String fileUnfValue = UNF5Util.calculateUNF(unfValues); porDataSection.setUnf(unfValues); porDataSection.setFileUnf(fileUnfValue); porDataSection.setData(dataTable2); smd.setVariableUNF(unfValues); smd.getFileInformation().put("fileUNF", fileUnfValue); }
From source file:edu.emory.cci.aiw.i2b2etl.ksb.I2b2KnowledgeSourceBackend.java
public String getMaritalStatusPropertyValueSetDelimiter() { return Character.toString(maritalStatusPropertyValueSetDelimiter); }