/** * Helper method to convert a list of codes into a string. * This method preserves the outerData in the codes. * @param list the list of the codes to flatten into a string. * @return the string with all the codes. * @see #codesToString(List, boolean) * @see #stringToCodes(String) */ public static String codesToString (List<Code> list) { return codesToString(list, false); // Keep outerData }
private static byte[] convertToByteArray (FragmentData data) { DataOutputStream dos = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); dos.writeUTF(data.codedText); dos.writeUTF(Code.codesToString(data.codes)); return bos.toByteArray(); } catch ( IOException e ) { return null; } finally { if ( dos != null ) { try { dos.close(); } catch ( IOException e ) {} } } }
private Field createCodesField(TranslationUnitField field, TextFragment frag, Field.Store store, Field.Index index) { // We don't keep the outerData in the codes return new Field(field.name(), Code.codesToString(frag.getCodes(), true), store, index); } }
/** * Creates a string that stores the content of a given container. * Use {@link #stringToContent(String)} to create the container back from the string. * <p> * <b>IMPORTANT:</b> Only the content is saved (not the properties, annotations, etc.). * * @param tc the container holding the content to store. * @return a string representing the content of the given container. */ public static String contentToString (TextContainer tc) { StringBuilder tmp = new StringBuilder(); tmp.append(tc.hasBeenSegmented() ? '1' : '0'); for ( TextPart part : tc ) { // part to string tmp.append(part.isSegment() ? '1' : '0'); tmp.append(part.text.getCodedText()); tmp.append(PARTSEP1); tmp.append(Code.codesToString(part.text.getCodes())); tmp.append(PARTSEP1); if ( part.isSegment() ) { tmp.append(((Segment)part).id); } // end of part to string: next part tmp.append(PARTSEP2); } return tmp.toString(); }
tmp2.append(Code.codesToString(part.text.getCodes())); tmp2.append(PARTSEP2);
pstm.setString(2, srcSeg.text.getCodedText()); pstm.setString(3, Code.codesToString(srcSeg.text.getCodes(), true)); Segment trgSeg = trgSegs.get(srcSeg.id); if ( trgSeg != null ) { // Skip source without target pstm.setString(4, trgSeg.text.getCodedText()); pstm.setString(5, Code.codesToString(trgSeg.text.getCodes(), true)); pstm.execute(); count++; pstm.setString(3, srcCont.getCodedText()); pstm.setString(4, Code.codesToString(srcCont.getFirstContent().getCodes(), true)); pstm.setString(5, trgCont.getCodedText()); pstm.setString(6, Code.codesToString(trgCont.getFirstContent().getCodes(), true)); pstm.setString(7, grpName); pstm.setString(8, fileName);
sb.append(",\n\t\t codes:{\n"); sb.append("\t\t\t"); sb.append(Code.codesToString(seg.text.getCodes()).replaceAll("\u009C", ", ").replace("\u009D", ";\n\t\t\t")); sb.append("} }");
/** * Writes a text fragment. * @param tf the text fragment to write out. */ public void write (TextFragment tf) { try { writeLongString(tf.getCodedText()); writeLongString(Code.codesToString(tf.getCodes())); } catch ( IOException e ) { throw new OkapiException("Error while writing.", e); } }
new TermQuery( new Term(TranslationUnitField.SOURCE_CODES.name(), Code.codesToString(srcFrag.getCodes(), true)) ), BooleanClause.Occur.MUST); indexWriter.deleteDocuments(bq);
String codeStr1 = Code.codesToString(codes1); String codeStr2 = Code.codesToString(codes2); if ( !codeStr1.equals(codeStr2) ) { LOGGER.warn("compareTextFragment warning: TextFragment Code string difference.\n" +
this.code.setMergedData(Code.codesToString(codes1));