public String addedCodesAsString() { StringBuffer b = new StringBuffer(); for (Code c : addedCodes) { b.append(c.getData()); b.append(','); } if (b.length() > 0) { // remove last comma b.deleteCharAt(b.length()-1); } return b.toString(); }
public String missingCodesAsString() { StringBuffer b = new StringBuffer(); for (Code c : missingCodes) { b.append(c.getData()); b.append(','); } if (b.length() > 0) { // remove last comma b.deleteCharAt(b.length()-1); } return b.toString(); } }
public void setCodes (List<Code> codes) { if ( Util.isEmpty(codes) ) { setString(GenericAnnotationType.LQI_XCODES, null); } else { StringBuilder values = new StringBuilder(); for ( Code code : codes ) { values.append(CODES_SEP); values.append(code.getData()); } // Final string is like this: "data1<sep>data2<sep>data3" setString(GenericAnnotationType.LQI_XCODES, values.toString().substring(1)); } }
@Override public int compare(Code c1, Code c2) { // FIXME: remove whitespace because the XLIFF/TMX etc.. code data may be normalized String data1 = StringUtil.removeWhiteSpace(c1.getData()); String data2 = StringUtil.removeWhiteSpace(c2.getData()); if (data1.equals(data2) && c1.getTagType() == c2.getTagType()) { return 0; } else if (data1.equals(data2) && c1.getTagType() != c2.getTagType()) { return c1.getTagType().compareTo(c2.tagType); } else { return data1.compareTo(data2); } } }
len += code.getData().length(); continue;
disp = makeDisplayCode(code); tmp.append(disp); sr = new StyleRange(code.getData().isEmpty() ? markStyle : codeStyle); sr.start = pos; sr.length = disp.length();
if (displayText == null && (tag == TAG.x || tag == TAG.bx || tag == TAG.ex || tag == TAG.g)) { displayText = code.getData();
} else if (!c.getData().isEmpty()) { c.setData(d); } else if (!c.getOuterData().isEmpty()) {
private void editCode () { Point selection = edit.getSelection(); if ( selection.x == selection.y ) { return; // Nothing is selected } FragmentData data = getSelection(selection); if (( data.codedText.length() != 2 ) || !TextFragment.isMarker(data.codedText.charAt(0)) ) { Dialogs.showError(edit.getShell(), "The selection must contain one code and one only.", null); return; } Code code = data.codes.get(0); InputDialog dlg = new InputDialog(edit.getShell(), "Edit Code", "Content of the code", code.getData(), null, 0, 50, 1); String res = dlg.showDialog(); if ( res == null ) return; // User cancellation // Else set the new code code.setData(res); setFragmentData(data, 2); }
private void checkInlineCodes (TextFragment tf) { if ( params.getUseCodeFinder() ) { params.getCodeFinder().process(tf); } // Escape inline code content List<Code> codes = tf.getCodes(); for ( Code code : codes ) { // Escape the data of the new inline code (and only them) if ( code.getType().equals(InlineCodeFinder.TAGTYPE) ) { code.setData(encoder.encode(code.getData(), EncoderContext.SKELETON)); } } }
case OPENING: xCode = xFrag.append(net.sf.okapi.lib.xliff2.core.TagType.OPENING, String.valueOf(code.getId()), code.getData(), mayOverlapDefault); break; case CLOSING: xCode = xFrag.append(net.sf.okapi.lib.xliff2.core.TagType.CLOSING, String.valueOf(code.getId()), code.getData(), mayOverlapDefault); break; case PLACEHOLDER: default: xCode = xFrag.appendCode(String.valueOf(code.getId()), code.getData()); break; String data = getReferences(code.getData()); if ( !Util.isEmpty(data) ) { xCode.setSubFlows(data);
final public String codeString() throws ParseException { if (jj_2_13(2)) { jj_consume_token(DATA); {if ("" != null) return code.getData() == null ? "" : code.getData();} } else if (jj_2_14(2)) { jj_consume_token(OUTER_DATA); {if ("" != null) return code.getOuterData() == null ? "" : code.getOuterData();} } else if (jj_2_15(2)) { jj_consume_token(ORIGINAL_ID); {if ("" != null) return code.getOriginalId() == null ? "" : code.getOriginalId();} } else if (jj_2_16(2)) { jj_consume_token(TYPE); {if ("" != null) return code.getType() == null ? "" : code.getType();} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); }
for ( Code code : issue.getCodes() ) { item = new MenuItem(contextMenu, SWT.PUSH); item.setData(code.getData()); if ( issue.getIssueType() == IssueType.EXTRA_CODE ) { item.setText(String.format("Allow \"%s\" as an Extra Code", code.getData())); item.addSelectionListener(allowExtraCodesAdapter); item.setText(String.format("Allow \"%s\" as a Missing Code", code.getData())); item.addSelectionListener(allowMissingCodesAdapter);
private void applyCodeFinder (TextFragment tf) { // Find the inline codes params.codeFinder.process(tf); // Escape inline code content List<Code> codes = tf.getCodes(); for ( Code code : codes ) { // Escape the data of the new inline code (and only them) if ( code.getType().equals(InlineCodeFinder.TAGTYPE) ) { if ( cfEncoder == null ) { encoderManager.setDefaultOptions(getParameters(), this.encoding, this.lineBreak); encoderManager.updateEncoder(getMimeType()); cfEncoder = getEncoderManager().getEncoder(); //TODO: We should use the proper output encoding here, not force UTF-8, but we do not know it cfEncoder.setOptions(params, "utf-8", lineBreak); } code.setData(cfEncoder.encode(code.getData(), EncoderContext.TEXT)); } } }
@Override protected ITextUnit postProcessTextUnit(ITextUnit textUnit) { TextFragment text = textUnit.getSource().getFirstContent(); String unescaped = unescape(text); text.setCodedText(unescaped); if (codeFinder != null) { encoderManager.updateEncoder(textUnit.getMimeType()); codeFinder.process(text); // Pre-emptively re-encode anything we parsed out, since it won't happen otherwise for (Code code : text.getCodes()) { code.setData(encoderManager.encode(code.getData(), EncoderContext.TEXT)); String codeDisplayText = code.getDisplayText(); if (codeDisplayText != null) { code.setDisplayText(encoderManager.encode(codeDisplayText, EncoderContext.TEXT)); } } } return textUnit; }
destFrag.delete(i-1, i+1); ctag = destFrag.insert(net.sf.okapi.lib.xliff2.core.TagType.OPENING, code.getType(), id, code.getData(), i-1, false, true); ctag.setDisp(code.getDisplayText()); ctag.setCanCopy(code.isCloneable()); destFrag.delete(i-1, i+1); ctag = destFrag.insert(net.sf.okapi.lib.xliff2.core.TagType.CLOSING, code.getType(), id, code.getData(), i-1, true, true); ctag.setDisp(code.getDisplayText()); ctag.setCanCopy(code.isCloneable()); destFrag.delete(i-1, i+1); ctag = destFrag.insert(net.sf.okapi.lib.xliff2.core.TagType.STANDALONE, code.getType(), id, code.getData(), i-1, false, true); ctag.setDisp(code.getDisplayText()); ctag.setCanCopy(code.isCloneable());
c.setData(Util.escapeToXML(c.getData(), 0, true, null)); if (c.hasOuterData()) { c.setOuterData(Util.escapeToXML(c.getOuterData(), 0, true, null));