Java Code Examples for javax.swing.text.MutableAttributeSet#getAttributeNames()
The following examples show how to use
javax.swing.text.MutableAttributeSet#getAttributeNames() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HtmlDocumentHandler.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** This method is called when the HTML parser encounts an empty tag */ @Override public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos){ // fire the status listener if the elements processed exceded the rate if ((++elements % ELEMENTS_RATE) == 0) fireStatusChangedEvent("Processed elements : " + elements); // construct a feature map from the attributes list // these are empty elements FeatureMap fm = Factory.newFeatureMap(); // take all the attributes an put them into the feature map if (0 != a.getAttributeCount ()){ // Out.println("HAS attributes = " + a.getAttributeCount ()); Enumeration<?> enumeration = a.getAttributeNames (); while (enumeration.hasMoreElements ()){ Object attribute = enumeration.nextElement (); fm.put ( attribute.toString(),(a.getAttribute(attribute)).toString()); }//while }//if // create the start index of the annotation Long startIndex = new Long(tmpDocContent.length()); // initialy the start index is equal with the End index CustomObject obj = new CustomObject(t.toString(),fm,startIndex,startIndex); // we add the object directly into the colector // we don't add it to the stack because this is an empty tag colector.add(obj); // Just analize the tag t and add some\n chars and spaces to the // tmpDocContent.The reason behind is that we need to have a readable form // for the final document. customizeAppearanceOfDocumentWithSimpleTag(t); }
Example 2
Source File: HtmlDocumentHandler.java From gate-core with GNU Lesser General Public License v3.0 | 4 votes |
/** This method is called when the HTML parser encounts the beginning * of a tag that means that the tag is paired by an end tag and it's * not an empty one. */ @Override public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) { // Fire the status listener if the elements processed exceded the rate if (0 == (++elements % ELEMENTS_RATE)) fireStatusChangedEvent("Processed elements : " + elements); // Start of STYLE tag if(HTML.Tag.STYLE.equals(t)) { isInsideStyleTag = true; } // if // Construct a feature map from the attributes list FeatureMap fm = Factory.newFeatureMap(); // Take all the attributes an put them into the feature map if (0 != a.getAttributeCount()){ Enumeration<?> enumeration = a.getAttributeNames(); while (enumeration.hasMoreElements()){ Object attribute = enumeration.nextElement(); fm.put(attribute.toString(),(a.getAttribute(attribute)).toString()); }// while }// if // Just analize the tag t and add some\n chars and spaces to the // tmpDocContent.The reason behind is that we need to have a readable form // for the final document. customizeAppearanceOfDocumentWithStartTag(t); // If until here the "tmpDocContent" ends with a NON whitespace char, // then we add a space char before calculating the START index of this // tag. // This is done in order not to concatenate the content of two separate tags // and obtain a different NEW word. int tmpDocContentSize = tmpDocContent.length(); if ( tmpDocContentSize != 0 && !Character.isWhitespace(tmpDocContent.charAt(tmpDocContentSize - 1)) ) tmpDocContent.append(" "); // create the start index of the annotation Long startIndex = new Long(tmpDocContent.length()); // initialy the start index is equal with the End index CustomObject obj = new CustomObject(t.toString(),fm,startIndex,startIndex); // put it into the stack stack.push (obj); }