List of usage examples for java.lang StringBuffer setLength
@Override public synchronized void setLength(int newLength)
From source file:com.vladium.emma.report.html.ReportGenerator.java
public Object visit(final ClassItem item, final Object ctx) { // this visit only takes place in class views HTMLWriter out = null;/* ww w .j a v a 2 s . c o m*/ try { final File outFile = getItemFile(NESTED_ITEMS_PARENT_DIR, m_reportIDNamespace.getID(getItemKey(item))); // TODO: deal with overwrites out = openOutFile(Files.newFile(m_settings.getOutDir(), outFile), m_settings.getOutEncoding(), true); final int[] columns = m_settings.getColumnOrder(); final StringBuffer buf = new StringBuffer(); // TODO: set title [from a prop?] final HTMLDocument page = createPage(REPORT_HEADER_TITLE); { final IItem[] path = getParentPath(item); addPageHeader(page, item, path); addPageFooter(page, item, path); } // summary table: { final IElement itemname = IElement.Factory.create(Tag.SPAN); itemname.setText(item.getName(), true); itemname.setClass(CSS_ITEM_NAME); final IElementList title = new ElementList(); title.add(new Text("COVERAGE SUMMARY FOR CLASS [", true)); title.add(itemname); title.add(new Text("]", true)); page.addH(1, title, null); } final HTMLTable summaryTable = new HTMLTable("100%", null, null, "0"); { // header row: final HTMLTable.IRow header = summaryTable.newTitleRow(); // coverage row: final HTMLTable.IRow coverage = summaryTable.newRow(); for (int c = 0; c < columns.length; ++c) { final int attrID = columns[c]; final IItemAttribute attr = item.getAttribute(attrID, m_settings.getUnitsType()); final HTMLTable.ICell headercell = header.newCell(); headercell.setText(attr.getName(), true); if (attr != null) { boolean fail = (m_metrics[attrID] > 0) && !attr.passes(item, m_metrics[attrID]); buf.setLength(0); attr.format(item, buf); final HTMLTable.ICell cell = coverage.newCell(); cell.setText(buf.toString(), true); if (fail) cell.setClass(CSS_DATA_HIGHLIGHT); } } } page.add(summaryTable); // child summary table: page.addH(2, "COVERAGE BREAKDOWN BY METHOD", null); final HTMLTable childSummaryTable = new HTMLTable("100%", null, null, "0"); { int[] headerColumns = null; boolean odd = true; final ItemComparator order = m_typeSortComparators[MethodItem.getTypeMetadata().getTypeID()]; for (Iterator methods = item.getChildren(order); methods.hasNext(); odd = !odd) { final MethodItem method = (MethodItem) methods.next(); if (headerColumns == null) { // header row: headerColumns = addHeaderRow(method, childSummaryTable, columns); } addItemRow(method, odd, childSummaryTable, headerColumns, null, false); } } page.add(childSummaryTable); page.emit(out); out.flush(); } finally { if (out != null) out.close(); out = null; } return ctx; }
From source file:com.vladium.emma.report.html.ReportGenerator.java
public Object visit(final PackageItem item, final Object ctx) { HTMLWriter out = null;// ww w. j ava 2 s .c om try { if (m_verbose) m_log.verbose(" report: processing package [" + item.getName() + "] ..."); final File outFile = getItemFile(NESTED_ITEMS_PARENT_DIR, m_reportIDNamespace.getID(getItemKey(item))); out = openOutFile(Files.newFile(m_settings.getOutDir(), outFile), m_settings.getOutEncoding(), true); final int[] columns = m_settings.getColumnOrder(); final StringBuffer buf = new StringBuffer(); // TODO: set title [from a prop?] final HTMLDocument page = createPage(REPORT_HEADER_TITLE); { final IItem[] path = getParentPath(item); addPageHeader(page, item, path); addPageFooter(page, item, path); } // summary table: { final IElement itemname = IElement.Factory.create(Tag.SPAN); itemname.setText(item.getName(), true); itemname.setClass(CSS_ITEM_NAME); final IElementList title = new ElementList(); title.add(new Text("COVERAGE SUMMARY FOR PACKAGE [", true)); title.add(itemname); title.add(new Text("]", true)); page.addH(1, title, null); } final HTMLTable summaryTable = new HTMLTable("100%", null, null, "0"); { // header row: final HTMLTable.IRow header = summaryTable.newTitleRow(); // coverage row: final HTMLTable.IRow coverage = summaryTable.newRow(); for (int c = 0; c < columns.length; ++c) { final int attrID = columns[c]; final IItemAttribute attr = item.getAttribute(attrID, m_settings.getUnitsType()); final HTMLTable.ICell headercell = header.newCell(); headercell.setText(attr.getName(), true); if (attr != null) { boolean fail = (m_metrics[attrID] > 0) && !attr.passes(item, m_metrics[attrID]); buf.setLength(0); attr.format(item, buf); final HTMLTable.ICell cell = coverage.newCell(); cell.setText(buf.toString(), true); if (fail) cell.setClass(CSS_DATA_HIGHLIGHT); } } } page.add(summaryTable); final boolean deeper = (m_settings.getDepth() > item.getMetadata().getTypeID()); // render child summary tables on the same page: final String summaryTitle = m_srcView ? "COVERAGE BREAKDOWN BY SOURCE FILE" : "COVERAGE BREAKDOWN BY CLASS"; page.addH(2, summaryTitle, null); final HTMLTable childSummaryTable = new HTMLTable("100%", null, null, "0"); { int[] headerColumns = null; boolean odd = true; final ItemComparator order = m_typeSortComparators[m_srcView ? SrcFileItem.getTypeMetadata().getTypeID() : ClassItem.getTypeMetadata().getTypeID()]; for (Iterator srcORclsFiles = item.getChildren(order); srcORclsFiles.hasNext(); odd = !odd) { final IItem srcORcls = (IItem) srcORclsFiles.next(); if (headerColumns == null) { // header row: headerColumns = addHeaderRow(srcORcls, childSummaryTable, columns); } // coverage row: String childHREF = null; if (deeper) { childHREF = getItemHREF(item, srcORcls); } addItemRow(srcORcls, odd, childSummaryTable, headerColumns, childHREF, false); if (deeper) m_queue.addLast(srcORcls); } } page.add(childSummaryTable); page.emit(out); out.flush(); } finally { if (out != null) out.close(); out = null; } return ctx; }
From source file:com.ikanow.infinit.e.api.knowledge.QueryHandler.java
BoolFilterBuilder parseOutputFiltering(String[] entityTypeFilterStrings, String[] assocVerbFilterStrings) { BoolFilterBuilder outputFilter = null; // First off: document discard aliases: if (null != _aliasLookup) { // Check out the document discard table... EntityFeaturePojo docDiscardAlias = _aliasLookup.getAliases("DOCUMENT_DISCARD"); if (null != docDiscardAlias) { outputFilter = addNegativeSelectorToFilter(docDiscardAlias, outputFilter, 0); }//w w w .jav a 2 s .co m } //TESTED (by hand, nothing repeatable) // Other simple filter types: if (null != entityTypeFilterStrings) { if ('-' != entityTypeFilterStrings[0].charAt(0)) { // (negative entity type, don't add to filter) outputFilter = FilterBuilders.boolFilter(); outputFilter.must(FilterBuilders.nestedFilter(DocumentPojo.entities_, FilterBuilders.termsFilter(EntityPojo.docQuery_type_, entityTypeFilterStrings))); } } if (null != assocVerbFilterStrings) { if ('-' != assocVerbFilterStrings[0].charAt(0)) { // (negative verb, don't add to filter) if (null == outputFilter) { outputFilter = FilterBuilders.boolFilter(); } BoolFilterBuilder verbFilter = FilterBuilders.boolFilter(); StringBuffer sb = new StringBuffer(); for (String assocVerb : assocVerbFilterStrings) { sb.setLength(0); sb.append('"').append(assocVerb).append('"'); verbFilter.should(FilterBuilders.nestedFilter(DocumentPojo.associations_, QueryBuilders .queryString(sb.toString()).field(AssociationPojo.docQuery_verb_category_))); //(closest to exact that we can manage, obv verb_cat should actually be not_analyzed) } outputFilter.must(verbFilter); } } return outputFilter; }
From source file:com.vladium.emma.report.html.ReportGenerator.java
public Object visit(final SrcFileItem item, final Object ctx) { // this visit only takes place in src views HTMLWriter out = null;/*from w w w. ja v a 2 s.com*/ try { final File outFile = getItemFile(NESTED_ITEMS_PARENT_DIR, m_reportIDNamespace.getID(getItemKey(item))); out = openOutFile(Files.newFile(m_settings.getOutDir(), outFile), m_settings.getOutEncoding(), true); final int[] columns = m_settings.getColumnOrder(); final StringBuffer buf = new StringBuffer(); // TODO: set title [from a prop?] final HTMLDocument page = createPage(REPORT_HEADER_TITLE); { final IItem[] path = getParentPath(item); addPageHeader(page, item, path); addPageFooter(page, item, path); } // summary table: { final IElement itemname = IElement.Factory.create(Tag.SPAN); itemname.setText(item.getName(), true); itemname.setClass(CSS_ITEM_NAME); final IElementList title = new ElementList(); title.add(new Text("COVERAGE SUMMARY FOR SOURCE FILE [", true)); title.add(itemname); title.add(new Text("]", true)); page.addH(1, title, null); } final HTMLTable summaryTable = new HTMLTable("100%", null, null, "0"); { // header row: final HTMLTable.IRow header = summaryTable.newTitleRow(); // coverage row: final HTMLTable.IRow coverage = summaryTable.newRow(); for (int c = 0; c < columns.length; ++c) { final int attrID = columns[c]; final IItemAttribute attr = item.getAttribute(attrID, m_settings.getUnitsType()); final HTMLTable.ICell headercell = header.newCell(); headercell.setText(attr.getName(), true); if (attr != null) { boolean fail = (m_metrics[attrID] > 0) && !attr.passes(item, m_metrics[attrID]); buf.setLength(0); attr.format(item, buf); final HTMLTable.ICell cell = coverage.newCell(); cell.setText(buf.toString(), true); if (fail) cell.setClass(CSS_DATA_HIGHLIGHT); } } } page.add(summaryTable); final boolean deeper = (m_settings.getDepth() > ClassItem.getTypeMetadata().getTypeID()); final boolean embedSrcFile = deeper && srcFileAvailable(item, m_cache); final boolean createAnchors = embedSrcFile && m_hasLineNumberInfo; final IDGenerator pageIDNamespace = createAnchors ? new IDGenerator() : null; // child summary table is special for srcfile items: page.addH(2, "COVERAGE BREAKDOWN BY CLASS AND METHOD", null); final IntObjectMap lineAnchorIDMap = embedSrcFile ? new IntObjectMap() : null; final HTMLTable childSummaryTable = new HTMLTable("100%", null, null, "0"); childSummaryTable.setClass(CSS_CLS_NOLEFT); { int[] headerColumns = null; final ItemComparator order = m_typeSortComparators[ClassItem.getTypeMetadata().getTypeID()]; int clsIndex = 0; for (Iterator classes = item.getChildren(order); classes.hasNext(); ++clsIndex) { final ClassItem cls = (ClassItem) classes.next(); if (headerColumns == null) { // header row: headerColumns = addHeaderRow(cls, childSummaryTable, columns); } String HREFname = null; // special class subheader: if (createAnchors) { if ($assert.ENABLED) { $assert.ASSERT(lineAnchorIDMap != null); $assert.ASSERT(pageIDNamespace != null); } final String childKey = getItemKey(cls); HREFname = addLineAnchorID(cls.getFirstLine(), pageIDNamespace.getID(childKey), lineAnchorIDMap); } addClassRow(cls, clsIndex, childSummaryTable, headerColumns, HREFname, createAnchors); // // row to separate this class's methods: // final HTMLTable.IRow subheader = childSummaryTable.newTitleRow (); // final HTMLTable.ICell cell = subheader.newCell (); // // TODO: cell.setColspan (???) // cell.setText ("class " + child.getName () + " methods:", true); boolean odd = false; final ItemComparator order2 = m_typeSortComparators[MethodItem.getTypeMetadata().getTypeID()]; for (Iterator methods = cls.getChildren(order2); methods.hasNext(); odd = !odd) { final MethodItem method = (MethodItem) methods.next(); HREFname = null; if (createAnchors) { if ($assert.ENABLED) { $assert.ASSERT(lineAnchorIDMap != null); $assert.ASSERT(pageIDNamespace != null); } final String child2Key = getItemKey(method); HREFname = addLineAnchorID(method.getFirstLine(), pageIDNamespace.getID(child2Key), lineAnchorIDMap); } addClassItemRow(method, odd, childSummaryTable, headerColumns, HREFname, createAnchors); } } } page.add(childSummaryTable); // embed source file: if (deeper) { //page.addHR (1); page.addEmptyP(); { embedSrcFileJson(item, m_cache); embedSrcFile(item, page, lineAnchorIDMap, m_cache); } //page.addHR (1); } page.emit(out); out.flush(); } finally { if (out != null) out.close(); out = null; } return ctx; }
From source file:org.LexGrid.util.sql.lgTables.SQLTableUtilities.java
/** * Add the root or tail relationship node for an association name in a * coding scheme.// w ww. ja va2 s . c o m * * @param codingScheme * The coding scheme to add the root node to. * @param associationNames * The association name(s) to calculate the root node for. If you * provide more than one association, the root node will be * calculated using all of the association names (at the same * time). If you don't provide any association names, all * associations names will be used (at the same time). * @param synNames * The association name(s) that define synonymous relationships * between concepts. If provided, nodes that do not directly * participate in an association above but are synonymous with a * node that does participate are not included in the * calculation. If empty or null, synonymy is not considered as * part of the calculation. * @param relationName * The relation name that contains the association. If null, the * native relation for the coding scheme is used. * @param root * - true for root, false for tail. * @throws SQLException */ public void addRootRelationNode(String codingScheme, String[] associationNames, String[] synNames, String relationName, boolean root) throws SQLException { if (!doTablesExist()) { log.debug("Tables don't exist - returning."); return; } String type = (root ? "root" : "tail"); boolean useAll = false; if (associationNames == null || associationNames.length == 0) { useAll = true; } Connection conn = getConnection(); try { if (relationName == null || relationName.length() < 1) { relationName = getNativeRelation(codingScheme); if (relationName == null || relationName.length() < 1) { log.debug("The relation could not be found."); return; } } StringBuffer query = new StringBuffer("SELECT " + stc_.targetEntityCodeOrId + " FROM " + stc_.getTableName(SQLTableConstants.ENTITY_ASSOCIATION_TO_ENTITY) + " WHERE " + stc_.codingSchemeNameOrId + " = ?" + " AND " + stc_.containerNameOrContainerDC + " = ?"); if (!useAll) { query.append(" AND ("); for (int i = 0; i < associationNames.length; i++) { query.append(stc_.entityCodeOrAssociationId + " = ? OR "); } // trim the last 'OR ' query.setLength(query.length() - 3); query.append(")"); } query.append( " AND " + stc_.sourceCSIdOrEntityCodeNS + " = ? AND " + stc_.targetCSIdOrEntityCodeNS + " = ?"); PreparedStatement checkForAssociation = conn.prepareStatement(gsm_.modifySQL(query.toString())); checkForAssociation.setMaxRows(1); int i = 1; checkForAssociation.setString(i++, codingScheme); checkForAssociation.setString(i++, relationName); if (!useAll) { for (int j = 0; j < associationNames.length; j++) { checkForAssociation.setString(i++, associationNames[j]); } } checkForAssociation.setString(i++, codingScheme); checkForAssociation.setString(i++, codingScheme); ResultSet results = checkForAssociation.executeQuery(); boolean hasResults = results.next(); results.close(); checkForAssociation.close(); if (!hasResults) { log.debug("None of the provided associations are present in the table. " + "No reason to calculate " + type + " nodes - returning "); return; } query.setLength(0); query.append("SELECT " + stc_.entityCodeOrId + " FROM " + stc_.getTableName(SQLTableConstants.ENTITY) + " WHERE " + stc_.codingSchemeNameOrId + " = ?" + " AND " + SQLTableConstants.TBLCOL_ISACTIVE + " = ?" + " AND " + stc_.entityCodeOrId + " NOT IN (" + " SELECT " + (root ? stc_.targetEntityCodeOrId : stc_.sourceEntityCodeOrId) + " FROM " + stc_.getTableName(SQLTableConstants.ENTITY_ASSOCIATION_TO_ENTITY) + " WHERE " + stc_.codingSchemeNameOrId + " = ?" + " AND " + stc_.containerNameOrContainerDC + " = ?"); if (!useAll) { query.append(" AND ("); for (int j = 0; j < associationNames.length; j++) { query.append(stc_.entityCodeOrAssociationId + " = ? OR "); } // trim the last 'OR ' query.setLength(query.length() - 3); query.append(")"); } query.append(" AND " + stc_.sourceCSIdOrEntityCodeNS + " = ? AND " + stc_.targetCSIdOrEntityCodeNS + " = ?)"); PreparedStatement getNodes = conn.prepareStatement(gsm_.modifySQL(query.toString())); PreparedStatement insertIntoConcepts = conn .prepareStatement(stc_.getInsertStatementSQL(SQLTableConstants.ENTITY)); PreparedStatement insertIntoConceptAssociationsToConcept = conn .prepareStatement(stc_.getInsertStatementSQL(SQLTableConstants.ENTITY_ASSOCIATION_TO_ENTITY)); PreparedStatement insertIntoAssociations = conn .prepareStatement(stc_.getInsertStatementSQL(SQLTableConstants.ASSOCIATION)); // add the node to the concepts table insertIntoConcepts.setString(1, codingScheme); insertIntoConcepts.setString(2, codingScheme); insertIntoConcepts.setString(3, (root ? "@" : "@@")); DBUtility.setBooleanOnPreparedStatment(insertIntoConcepts, 4, null); DBUtility.setBooleanOnPreparedStatment(insertIntoConcepts, 5, null); DBUtility.setBooleanOnPreparedStatment(insertIntoConcepts, 6, new Boolean(true)); insertIntoConcepts.setInt(7, 0); // entryStateId here insertIntoConcepts.setString(8, type + " relation node for relations"); try { insertIntoConcepts.executeUpdate(); } catch (SQLException e) { // assume this means that the association is already in the // table. } insertIntoConcepts.close(); // if they ask me to calculate root nodes based on multiple // associations // then I want to use a special association name to mark this one. // need // to add it to the associations table, so I don't have foreign key // violations. // if they only provide one association name, then I will just use // that association // name. if (useAll || associationNames.length > 1) { int k = 1; insertIntoAssociations.setString(k++, codingScheme); insertIntoAssociations.setString(k++, relationName); insertIntoAssociations.setString(k++, codingScheme); insertIntoAssociations.setString(k++, "-multi-assn-@-root-"); insertIntoAssociations.setString(k++, "-multi-assn-@-root-"); insertIntoAssociations.setString(k++, "Not Applicable"); insertIntoAssociations.setString(k++, "Not Applicable"); insertIntoAssociations.setString(k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoAssociations, k++, null); if (stc_.supports2009Model()) insertIntoAssociations.setInt(k++, -1);// entryStateId insertIntoAssociations.setString(k++, null); try { insertIntoAssociations.executeUpdate(); } catch (SQLException e) { // assume this means it already exists } insertIntoAssociations.close(); } // find all the nodes that need to be referenced and insert rows for // them i = 1; getNodes.setString(i++, codingScheme); DBUtility.setBooleanOnPreparedStatment(getNodes, i++, new Boolean(true)); getNodes.setString(i++, codingScheme); getNodes.setString(i++, relationName); if (!useAll) { for (int j = 0; j < associationNames.length; j++) { getNodes.setString(i++, associationNames[j]); } } getNodes.setString(i++, codingScheme); getNodes.setString(i++, codingScheme); results = getNodes.executeQuery(); Set candidateCodes = new HashSet(); try { while (results.next()) { String target = results.getString(stc_.entityCodeOrId); if (target.equals((root ? "@" : "@@"))) { // Already linked to root; don't add this one continue; } // Add code as candidate to be linked to root candidateCodes.add(target); } } finally { results.close(); getNodes.close(); } // If synonymous relations are indicated, filter candidates having // synonymous concepts not in the candidate list. if (synNames != null && synNames.length > 0) { StringBuffer sb = new StringBuffer("SELECT " + stc_.targetEntityCodeOrId + " FROM ") .append(stc_.getTableName(SQLTableConstants.ENTITY_ASSOCIATION_TO_ENTITY)) .append(" WHERE " + stc_.codingSchemeNameOrId + " = '").append(codingScheme).append('\'') .append(" AND " + stc_.containerNameOrContainerDC + " = '").append(relationName) .append('\'').append(" AND " + stc_.sourceEntityCodeOrId + " = ?") .append(" AND " + stc_.entityCodeOrAssociationId + " IN ("); for (int s = 0; s < synNames.length; s++) { if (s > 0) sb.append(','); sb.append('\'').append(synNames[s]).append('\''); } sb.append(")"); PreparedStatement getSynonyms = conn.prepareStatement(gsm_.modifySQL(sb.toString())); try { // Check each concept tagged as a synonym. Collection codesToRemove = new ArrayList(); for (Iterator sourceCodes = candidateCodes.iterator(); sourceCodes.hasNext();) { String sourceCode = (String) sourceCodes.next(); getSynonyms.setString(1, sourceCode); ResultSet rs = getSynonyms.executeQuery(); try { // Is the synonym's code participating as an // intermediate node // in the hierarchy? while (rs.next()) { String synCode = rs.getString(1); if (!candidateCodes.contains(synCode)) { codesToRemove.add(sourceCode); break; } } } finally { rs.close(); } } // Remove those detected to have a synonym that is not a // root node. candidateCodes.removeAll(codesToRemove); } finally { getSynonyms.close(); } } // Insert root relations for remaining candidates for (Iterator candidates = candidateCodes.iterator(); candidates.hasNext();) { String target = (String) candidates.next(); int col = 1; insertIntoConceptAssociationsToConcept.setString(col++, codingScheme); insertIntoConceptAssociationsToConcept.setString(col++, relationName); insertIntoConceptAssociationsToConcept.setString(col++, codingScheme); // use a special association name if there is more than one // association provided. insertIntoConceptAssociationsToConcept.setString(col++, ((useAll || associationNames.length > 1) ? "-multi-assn-@-root-" : associationNames[0])); insertIntoConceptAssociationsToConcept.setString(col++, codingScheme); if (root) { insertIntoConceptAssociationsToConcept.setString(col++, "@"); } else { insertIntoConceptAssociationsToConcept.setString(col++, target); } insertIntoConceptAssociationsToConcept.setString(col++, codingScheme); if (root) { insertIntoConceptAssociationsToConcept.setString(col++, target); } else { insertIntoConceptAssociationsToConcept.setString(col++, "@@"); } //always populate the multiattributeskey -- in this case a random UUID insertIntoConceptAssociationsToConcept.setString(col++, UUID.randomUUID().toString()); insertIntoConceptAssociationsToConcept.setString(col++, null); DBUtility.setBooleanOnPreparedStatment(insertIntoConceptAssociationsToConcept, col++, new Boolean(null)); DBUtility.setBooleanOnPreparedStatment(insertIntoConceptAssociationsToConcept, col++, new Boolean(null)); DBUtility.setBooleanOnPreparedStatment(insertIntoConceptAssociationsToConcept, col++, new Boolean(null)); insertIntoConceptAssociationsToConcept.setInt(col++, 0); // entryStateId // here insertIntoConceptAssociationsToConcept.executeUpdate(); } insertIntoConceptAssociationsToConcept.close(); } finally { returnConnection(conn); } }
From source file:com.ikanow.infinit.e.api.knowledge.QueryHandler.java
private BaseQueryBuilder parseQueryTerm(AdvancedQueryPojo.QueryTermPojo qt, StringBuffer sQueryTerm) { BaseQueryBuilder term = null;//from w ww .j av a2 s . c o m BoolQueryBuilder boolTerm = null; sQueryTerm.setLength(0); sQueryTerm.append('('); // 1.1] Free text (Lucene) boolean nonEmpty = false; if (null != qt.ftext) { // NOTE term building code below depends on this being 1st clause nonEmpty = true; if (qt.ftext.startsWith("$cache")) { // currently not supported throw new RuntimeException("Don't currently support nested cached queries - coming soon."); } sQueryTerm.append('('); if (null != qt.metadataField) { sQueryTerm.append(qt.metadataField).append(':'); } sQueryTerm.append(qt.ftext); sQueryTerm.append(')'); if (null != qt.metadataField) { // Metadata only term = QueryBuilders.queryString(qt.ftext).field(qt.metadataField); } else { term = QueryBuilders.queryString(qt.ftext).field("_all").field(DocumentPojo.fullText_); } if ((null == _scoringParams) || (null == _scoringParams.adjustAggregateSig)) { // auto-decide .. if ftext is set and is non-trivial if (qt.ftext.contains(" ")) { _scoringParams.adjustAggregateSig = true; } } } //TESTED (logic0) // 1.2] Exact text if (null != qt.etext) { // NOTE term building code below depends on this being 2nd clause nonEmpty = true; BaseQueryBuilder termQ = null; if (sQueryTerm.length() > 1) { sQueryTerm.append(" AND "); } if (qt.etext.equals("*")) { // Special case termQ = QueryBuilders.matchAllQuery(); } else { // Normal query if (null != qt.metadataField) { // Metadata only termQ = CrossVersionQueryBuilders.matchPhraseQuery(qt.metadataField, qt.etext); } else { // Normal query termQ = QueryBuilders.boolQuery() .should(CrossVersionQueryBuilders.matchPhraseQuery("_all", qt.etext)) .should(CrossVersionQueryBuilders.matchPhraseQuery(DocumentPojo.fullText_, qt.etext)); } } sQueryTerm.append('('); if (null != qt.metadataField) { sQueryTerm.append(qt.metadataField).append(':'); } sQueryTerm.append('"'); sQueryTerm.append(qt.etext); sQueryTerm.append("\")"); if (null == term) { term = termQ; } else { term = (boolTerm = QueryBuilders.boolQuery().must(term).must(termQ)); } } //TESTED (logic1) // Here's where it starts getting interesting: // 1.3] Entity if ((null != qt.entity) || (null != qt.entityValue) || ((null == qt.assoc) && (null != qt.sentiment))) { // (if no association specified then sentiment applies to entities) nonEmpty = true; if (sQueryTerm.length() > 1) { sQueryTerm.append(" AND "); } sQueryTerm.append('('); BaseQueryBuilder termQ = QueryBuilders .nestedQuery(DocumentPojo.entities_, this.parseEntityTerm(qt, sQueryTerm, EntityPojo.docQuery_index_)) .scoreMode("max").boost((float) 1.0); if (null == term) { term = termQ; } else if (null == boolTerm) { term = (boolTerm = QueryBuilders.boolQuery().must(term).must(termQ)); } else { term = (boolTerm = boolTerm.must(termQ)); } sQueryTerm.append(')'); } //TESTED: logic2* TOTEST: alias expansion code (logic3) // 1.4] Dates if (null != qt.time) { nonEmpty = true; if (sQueryTerm.length() > 1) { sQueryTerm.append(" AND "); } sQueryTerm.append('('); BaseQueryBuilder termQ = this.parseDateTerm(qt.time, sQueryTerm, (null != qt.entityOpt) && qt.entityOpt.lockDate); if (null == term) { term = termQ; } else if (null == boolTerm) { term = (boolTerm = QueryBuilders.boolQuery().must(term).must(termQ)); } else { term = (boolTerm = boolTerm.must(termQ)); } sQueryTerm.append(')'); } //TESTED (logic5-10) // 1.5] Geo if (null != qt.geo) { nonEmpty = true; if (sQueryTerm.length() > 1) { sQueryTerm.append(" AND "); } sQueryTerm.append('('); BaseQueryBuilder termQ = this.parseGeoTerm(qt.geo, sQueryTerm, GeoParseField.ALL); if (null != termQ) { if (null == term) { term = termQ; } else if (null == boolTerm) { term = (boolTerm = QueryBuilders.boolQuery().must(term).must(termQ)); } else { term = (boolTerm = boolTerm.must(termQ)); } } sQueryTerm.append(')'); } // (end geo) if (null == qt.assoc) qt.assoc = qt.event; //(continue to support the old "event" name for another release) if (null != qt.assoc) { nonEmpty = true; if (sQueryTerm.length() > 1) { sQueryTerm.append(" AND "); } sQueryTerm.append('('); BaseQueryBuilder termQ = QueryBuilders.nestedQuery(DocumentPojo.associations_, this.parseAssociationTerm(qt.assoc, qt.sentiment, sQueryTerm)); if (null != termQ) { if (null == term) { term = termQ; } else if (null == boolTerm) { term = (boolTerm = QueryBuilders.boolQuery().must(term).must(termQ)); } else { term = (boolTerm = boolTerm.must(termQ)); } } sQueryTerm.append(')'); } // (end event) if (!nonEmpty) { throw new RuntimeException("One+ of your query terms is empty!"); } //TOTEST sQueryTerm.append(')'); return term; }
From source file:com.pureinfo.srm.patent.domain.impl.PatentMgrImpl.java
/** * /*from w w w. ja v a2s . c o m*/ * * @param _patent * @param _nNumDays * @param _bIsAuth * * @return * @throws PureException */ private String getEmailContent(Patent _patent, int _nNumDays, boolean _bIsAuth) throws PureException { if (_patent == null) { throw new PureException(PureException.INVALID_VALUE, ""); } StringBuffer sbuff = new StringBuffer(); try { sbuff.append(_patent.getAdministratorName()).append(":\n"); sbuff.append(" !\n"); sbuff.append(" ").append(_patent.getName()).append(""); if (_bIsAuth) { sbuff.append(""); } else { sbuff.append(""); sbuff.append(_nNumDays).append(""); } sbuff.append("\n"); if (!_bIsAuth) { IPatentFeeYearMgr feeYearMgr = (IPatentFeeYearMgr) ArkContentHelper .getContentMgrOf(PatentFeeYear.class); PatentFeeYear feeYear = feeYearMgr.getLatestOf(_patent.getId()); if (feeYear == null) { sbuff.append(" "); } else { sbuff.append(" "); if (feeYear.getPayDate() != null) { sbuff.append(ForceConstants.DATE_FORMAT.format(feeYear.getPayDate())); } } sbuff.append("") .append(ForceConstants.DATE_FORMAT.format(_patent.getYearFeeDate())); sbuff.append("\n"); } sbuff.append("\n").append(_patent.getName()).append("").append("\n"); sbuff.append("").append(_patent.getPatentSid()).append('\n'); sbuff.append("").append(_patent.getName()).append('\n'); sbuff.append("").append(ForceConstants.DATE_FORMAT.format(_patent.getApplyDate())) .append('\n'); sbuff.append(""); if (!this.openIsAuth(_patent.getPatentType())) { sbuff.append(ForceConstants.DATE_FORMAT.format(_patent.getWarrantDate())); } else { sbuff.append(ForceConstants.DATE_FORMAT.format( (_patent.getPublicDate() != null) ? _patent.getPublicDate() : _patent.getWarrantDate())); } sbuff.append('\n'); sbuff.append("").append(_patent.getAdministratorName()).append("\n\n"); sbuff.append("\n"); String sPatentOfficer = PureSystem.getProperty("patent.officer", ""); String sTelePhone = PureSystem.getProperty("product.office.telephone", ""); if (sPatentOfficer != null && sPatentOfficer.length() > 0) sbuff.append(sPatentOfficer); if (sTelePhone != null && sTelePhone.length() > 0) sbuff.append(" ").append(sTelePhone); return sbuff.toString(); } finally { sbuff.setLength(0); } }
From source file:com.tremolosecurity.provisioning.core.providers.BasicDB.java
@Override public User findUser(String userID, Set<String> attributes, Map<String, Object> request) throws ProvisioningException { StringBuffer select = new StringBuffer(); //select.append("SELECT ").append(this.userPrimaryKey).append(" "); StringBuffer selAttrs = new StringBuffer(); this.getFieldName(this.userPrimaryKey, selAttrs).append(" "); for (String attr : attributes) { if (!attr.equalsIgnoreCase("TREMOLO_USER_ID")) { selAttrs.append(", "); getFieldName(attr, selAttrs).append(" "); }/*w ww .j av a 2 s . c o m*/ } if (this.userTable != null) { select.append("SELECT ").append(selAttrs).append(" FROM ").append(this.userTable).append(" WHERE "); this.getFieldName(this.userName, select).append("=?"); } else { select.append(this.userSQL.replaceAll("\\%S", selAttrs.toString()).replaceAll("\\%L", "?")); } Connection con = null; try { con = this.ds.getConnection(); if (logger.isDebugEnabled()) { logger.debug("Search string : '" + select.toString() + "'"); } PreparedStatement ps = con.prepareStatement(select.toString()); if (logger.isDebugEnabled()) { logger.debug("User ID : '" + userID + "'"); } ps.setString(1, userID); ResultSet rs = ps.executeQuery(); if (!rs.next()) { if (!logger.isDebugEnabled()) { logger.debug("User not found"); } rs.close(); ps.close(); con.close(); return null; } User user = new User(userID); for (String attr : attributes) { if (!attr.equalsIgnoreCase("TREMOLO_USER_ID")) { String val = rs.getString(attr); if (val != null) { user.getAttribs().put(attr, new Attribute(attr, val)); } } } int userKey = rs.getInt(this.userPrimaryKey); rs.close(); ps.close(); switch (this.groupMode) { case None: break; case One2Many: select.setLength(0); select.append("SELECT "); getFieldName(this.groupName, select).append(" FROM ").append(this.groupTable).append(" WHERE "); this.getFieldName(this.groupUserKey, select).append("=?"); ps = con.prepareStatement(select.toString()); ps.setInt(1, userKey); rs = ps.executeQuery(); while (rs.next()) { user.getGroups().add(rs.getString(this.groupName)); } break; case Many2Many: many2manyLoadGroups(select, con, user, userKey); break; case Custom: if (this.customDBProvider != null && this.customDBProvider.listCustomGroups()) { user.getGroups().addAll(this.customDBProvider.findGroups(con, userKey, request)); } else { select.setLength(0); select.append(this.groupSQL.replaceAll("\\%S", this.groupName).replaceAll("\\%I", "?")); ps = con.prepareStatement(select.toString()); ps.setInt(1, userKey); rs = ps.executeQuery(); while (rs.next()) { user.getGroups().add(rs.getString(this.groupName)); } } break; } if (logger.isDebugEnabled()) { logger.debug("Returning user : '" + user.getUserID() + "'"); } return user; } catch (Exception e) { throw new ProvisioningException("could not find user", e); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { } } } }
From source file:au.org.ala.biocache.dao.SearchDAOImpl.java
/** * Format the search input query for a full-text search. * * This includes constructing a user friendly version of the query to * be used for display purposes.//from w ww .j a v a 2 s . c o m * * TODO Fix this to use a state. REVISE!! * * @param searchParams */ protected void formatSearchQuery(SpatialSearchRequestParams searchParams, boolean forceQueryFormat) { //Only format the query if it doesn't already supply a formattedQuery. if (forceQueryFormat || StringUtils.isEmpty(searchParams.getFormattedQuery())) { // set the query String query = searchParams.getQ(); //cached query parameters are already formatted if (query.contains("qid:")) { Matcher matcher = qidPattern.matcher(query); long qid = 0; while (matcher.find()) { String value = matcher.group(); try { String qidValue = SearchUtils.stripEscapedQuotes(value.substring(4)); qid = Long.parseLong(qidValue); ParamsCacheObject pco = ParamsCache.get(qid); if (pco != null) { searchParams.setQId(qid); searchParams.setQ(pco.getQ()); //add the fqs from the params cache if (pco.getFqs() != null) { String[] currentFqs = searchParams.getFq(); if (currentFqs == null || (currentFqs.length == 1 && currentFqs[0].length() == 0)) { searchParams.setFq(pco.getFqs()); } else { //we need to add the current Fqs together searchParams.setFq((String[]) ArrayUtils.addAll(currentFqs, pco.getFqs())); } } String displayString = pco.getDisplayString(); if (StringUtils.isNotEmpty(pco.getWkt())) { displayString = displayString + " within user defined polygon"; } searchParams.setDisplayString(displayString); if (searchParams instanceof SpatialSearchRequestParams) { ((SpatialSearchRequestParams) searchParams).setWkt(pco.getWkt()); } else if (StringUtils.isNotEmpty(pco.getWkt())) { String originalQ = searchParams.getQ(); searchParams.setQ(spatialField + ":\"Intersects(" + pco.getWkt() + ")"); if (StringUtils.isNotEmpty(originalQ)) searchParams.setQ(searchParams.getQ() + " AND " + originalQ); } searchParams.setFormattedQuery(searchParams.getQ()); return; } } catch (NumberFormatException e) { } catch (ParamsCacheMissingException e) { } } } StringBuffer queryString = new StringBuffer(); StringBuffer displaySb = new StringBuffer(); String displayString = query; // look for field:term sub queries and catch fields: matched_name & matched_name_children if (query.contains(":")) { // will match foo:bar, foo:"bar bash" & foo:bar\ bash Matcher matcher = termPattern.matcher(query); queryString.setLength(0); while (matcher.find()) { String value = matcher.group(); logger.debug("term query: " + value); logger.debug("groups: " + matcher.group(1) + "|" + matcher.group(2)); if ("matched_name".equals(matcher.group(1))) { // name -> accepted taxon name (taxon_name:) String field = matcher.group(1); String queryText = matcher.group(2); if (queryText != null && !queryText.isEmpty()) { String guid = speciesLookupService.getGuidForName(queryText.replaceAll("\"", "")); // strip any quotes logger.info("GUID for " + queryText + " = " + guid); if (guid != null && !guid.isEmpty()) { String acceptedName = speciesLookupService.getAcceptedNameForGuid(guid); // strip any quotes logger.info("acceptedName for " + queryText + " = " + acceptedName); if (acceptedName != null && !acceptedName.isEmpty()) { field = "taxon_name"; queryText = acceptedName; } } else { field = "taxon_name"; } // also change the display query displayString = displayString.replaceAll("matched_name", "taxon_name"); } if (StringUtils.containsAny(queryText, CHARS) && !queryText.startsWith("[")) { // quote any text that has spaces or colons but not range queries queryText = QUOTE + queryText + QUOTE; } logger.debug("queryText: " + queryText); matcher.appendReplacement(queryString, matcher.quoteReplacement(field + ":" + queryText)); } else if ("matched_name_children".equals(matcher.group(1))) { String field = matcher.group(1); String queryText = matcher.group(2); if (queryText != null && !queryText.isEmpty()) { String guid = speciesLookupService.getGuidForName(queryText.replaceAll("\"", "")); // strip any quotes logger.info("GUID for " + queryText + " = " + guid); if (guid != null && !guid.isEmpty()) { field = "lsid"; queryText = guid; } else { field = "taxon_name"; } } if (StringUtils.containsAny(queryText, CHARS) && !queryText.startsWith("[")) { // quote any text that has spaces or colons but not range queries queryText = QUOTE + queryText + QUOTE; } matcher.appendReplacement(queryString, matcher.quoteReplacement(field + ":" + queryText)); } else { matcher.appendReplacement(queryString, matcher.quoteReplacement(value)); } } matcher.appendTail(queryString); query = queryString.toString(); } //if the query string contains lsid: we will need to replace it with the corresponding lft range int last = 0; if (query.contains("lsid:")) { Matcher matcher = lsidPattern.matcher(query); queryString.setLength(0); while (matcher.find()) { //only want to process the "lsid" if it does not represent taxon_concept_lsid etc... if ((matcher.start() > 0 && query.charAt(matcher.start() - 1) != '_') || matcher.start() == 0) { String value = matcher.group(); logger.debug("preprocessing " + value); String lsid = matcher.group(2); if (lsid.contains("\"")) { //remove surrounding quotes, if present lsid = lsid.replaceAll("\"", ""); } if (lsid.contains("\\")) { //remove internal \ chars, if present //noinspection MalformedRegex lsid = lsid.replaceAll("\\\\", ""); } logger.debug("lsid = " + lsid); String[] values = searchUtils.getTaxonSearch(lsid); String lsidHeader = matcher.group(1).length() > 0 ? matcher.group(1) : ""; matcher.appendReplacement(queryString, lsidHeader + values[0]); displaySb.append(query.substring(last, matcher.start())); if (!values[1].startsWith("taxon_concept_lsid:")) displaySb.append(lsidHeader).append("<span class='lsid' id='").append(lsid).append("'>") .append(values[1]).append("</span>"); else displaySb.append(lsidHeader).append(values[1]); last = matcher.end(); //matcher.appendReplacement(displayString, values[1]); } } matcher.appendTail(queryString); displaySb.append(query.substring(last, query.length())); query = queryString.toString(); displayString = displaySb.toString(); } if (query.contains("urn")) { //escape the URN strings before escaping the rest this avoids the issue with attempting to search on a urn field Matcher matcher = urnPattern.matcher(query); queryString.setLength(0); while (matcher.find()) { String value = matcher.group(); logger.debug("escaping lsid urns " + value); matcher.appendReplacement(queryString, prepareSolrStringForReplacement(value)); } matcher.appendTail(queryString); query = queryString.toString(); } if (query.contains("Intersects")) { Matcher matcher = spatialPattern.matcher(query); if (matcher.find()) { String spatial = matcher.group(); SpatialSearchRequestParams subQuery = new SpatialSearchRequestParams(); logger.debug("region Start : " + matcher.regionStart() + " start : " + matcher.start() + " spatial length " + spatial.length() + " query length " + query.length()); //format the search query of the remaining text only subQuery.setQ(query.substring(matcher.start() + spatial.length(), query.length())); //format the remaining query formatSearchQuery(subQuery); //now append Q's together queryString.setLength(0); //need to include the prefix queryString.append(query.substring(0, matcher.start())); queryString.append(spatial); queryString.append(subQuery.getFormattedQuery()); searchParams.setFormattedQuery(queryString.toString()); //add the spatial information to the display string if (spatial.contains("circles")) { String[] values = spatial.substring(spatial.indexOf("=") + 1, spatial.indexOf("}")) .split(","); if (values.length == 3) { displaySb.setLength(0); displaySb.append(subQuery.getDisplayString()); displaySb.append(" - within ").append(values[2]).append(" km of point(") .append(values[0]).append(",").append(values[1]).append(")"); searchParams.setDisplayString(displaySb.toString()); } } else { searchParams.setDisplayString(subQuery.getDisplayString() + " - within supplied region"); } } } else { //escape reserved characters unless the colon represnts a field name colon queryString.setLength(0); Matcher matcher = spacesPattern.matcher(query); while (matcher.find()) { String value = matcher.group(); //special cases to ignore from character escaping //if the value is a single - or * it means that we don't want to escape it as it is likely to have occurred in the following situation -(occurrence_date:[* TO *]) or *:* if (!value.equals("-") && /*!value.equals("*") && !value.equals("*:*") && */ !value.endsWith("*")) { //split on the colon String[] bits = StringUtils.split(value, ":", 2); if (bits.length == 2) { if (!bits[0].contains("urn") && !bits[1].contains("urn\\")) matcher.appendReplacement(queryString, bits[0] + ":" + prepareSolrStringForReplacement(bits[1])); } else if (!value.endsWith(":")) { //need to ignore field names where the : is at the end because the pattern matching will return field_name: as a match when it has a double quoted value //default behaviour is to escape all matcher.appendReplacement(queryString, prepareSolrStringForReplacement(value)); } } } matcher.appendTail(queryString); //substitute better display strings for collection/inst etc searches if (displayString.contains("_uid")) { displaySb.setLength(0); String normalised = displayString.replaceAll("\"", ""); matcher = uidPattern.matcher(normalised); while (matcher.find()) { String newVal = "<span>" + searchUtils.getUidDisplayString(matcher.group(1), matcher.group(2)) + "</span>"; if (newVal != null) matcher.appendReplacement(displaySb, newVal); } matcher.appendTail(displaySb); displayString = displaySb.toString(); } if (searchParams.getQ().equals("*:*")) { displayString = "[all records]"; } if (searchParams.getLat() != null && searchParams.getLon() != null && searchParams.getRadius() != null) { displaySb.setLength(0); displaySb.append(displayString); displaySb.append(" - within ").append(searchParams.getRadius()).append(" km of point(") .append(searchParams.getLat()).append(",").append(searchParams.getLon()).append(")"); displayString = displaySb.toString(); } // substitute i18n version of field name, if found in messages.properties displayString = formatDisplayStringWithI18n(displayString); searchParams.setFormattedQuery(queryString.toString()); logger.debug("formattedQuery = " + queryString); logger.debug("displayString = " + displayString); searchParams.setDisplayString(displayString); } //format the fq's for facets that need ranges substituted for (int i = 0; i < searchParams.getFq().length; i++) { String fq = searchParams.getFq()[i]; String[] parts = fq.split(":", 2); //check to see if the first part is a range based query and update if necessary Map<String, String> titleMap = RangeBasedFacets.getTitleMap(parts[0]); if (titleMap != null) { searchParams.getFq()[i] = titleMap.get(parts[1]); } } } searchParams.setDisplayString(formatDisplayStringWithI18n(searchParams.getDisplayString())); }
From source file:org.apache.fop.afp.DataStream.java
/** * Helper method to create text on the current page, this method delegates * to the current presentation text object in order to construct the text. * * @param textDataInfo the afp text data * @param letterSpacing letter spacing to draw text with * @param wordSpacing word Spacing to draw text with * @param font is the font to draw text with * @param charSet is the AFP Character Set to use with the text * @throws UnsupportedEncodingException thrown if character encoding is not supported */// w w w.j a v a 2s.c o m public void createText(final AFPTextDataInfo textDataInfo, final int letterSpacing, final int wordSpacing, final Font font, final CharacterSet charSet) throws UnsupportedEncodingException { int rotation = paintingState.getRotation(); if (rotation != 0) { textDataInfo.setRotation(rotation); Point p = getPoint(textDataInfo.getX(), textDataInfo.getY()); textDataInfo.setX(p.x); textDataInfo.setY(p.y); } // use PtocaProducer to create PTX records PtocaProducer producer = new PtocaProducer() { public void produce(PtocaBuilder builder) throws IOException { builder.setTextOrientation(textDataInfo.getRotation()); builder.absoluteMoveBaseline(textDataInfo.getY()); builder.absoluteMoveInline(textDataInfo.getX()); builder.setExtendedTextColor(textDataInfo.getColor()); builder.setCodedFont((byte) textDataInfo.getFontReference()); int l = textDataInfo.getString().length(); StringBuffer sb = new StringBuffer(); int interCharacterAdjustment = 0; AFPUnitConverter unitConv = paintingState.getUnitConverter(); if (letterSpacing != 0) { interCharacterAdjustment = Math.round(unitConv.mpt2units(letterSpacing)); } builder.setInterCharacterAdjustment(interCharacterAdjustment); int spaceWidth = font.getCharWidth(CharUtilities.SPACE); int spacing = spaceWidth + letterSpacing; int fixedSpaceCharacterIncrement = Math.round(unitConv.mpt2units(spacing)); int varSpaceCharacterIncrement = fixedSpaceCharacterIncrement; if (wordSpacing != 0) { varSpaceCharacterIncrement = Math .round(unitConv.mpt2units(spaceWidth + wordSpacing + letterSpacing)); } builder.setVariableSpaceCharacterIncrement(varSpaceCharacterIncrement); boolean fixedSpaceMode = false; for (int i = 0; i < l; i++) { char orgChar = textDataInfo.getString().charAt(i); float glyphAdjust = 0; if (CharUtilities.isFixedWidthSpace(orgChar)) { flushText(builder, sb, charSet); builder.setVariableSpaceCharacterIncrement(fixedSpaceCharacterIncrement); fixedSpaceMode = true; sb.append(CharUtilities.SPACE); int charWidth = font.getCharWidth(orgChar); glyphAdjust += (charWidth - spaceWidth); } else { if (fixedSpaceMode) { flushText(builder, sb, charSet); builder.setVariableSpaceCharacterIncrement(varSpaceCharacterIncrement); fixedSpaceMode = false; } char ch; if (orgChar == CharUtilities.NBSPACE) { ch = ' '; //converted to normal space to allow word spacing } else { ch = orgChar; } sb.append(ch); } if (glyphAdjust != 0) { flushText(builder, sb, charSet); int increment = Math.round(unitConv.mpt2units(glyphAdjust)); builder.relativeMoveInline(increment); } } flushText(builder, sb, charSet); } private void flushText(PtocaBuilder builder, StringBuffer sb, final CharacterSet charSet) throws IOException { if (sb.length() > 0) { builder.addTransparentData(charSet.encodeChars(sb)); sb.setLength(0); } } }; currentPage.createText(producer); }