當前位置: 首頁>>代碼示例>>Java>>正文


Java MutableAttributeSet.getAttributeNames方法代碼示例

本文整理匯總了Java中javax.swing.text.MutableAttributeSet.getAttributeNames方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableAttributeSet.getAttributeNames方法的具體用法?Java MutableAttributeSet.getAttributeNames怎麽用?Java MutableAttributeSet.getAttributeNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.MutableAttributeSet的用法示例。


在下文中一共展示了MutableAttributeSet.getAttributeNames方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleSimpleTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
/** 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);

}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:42,代碼來源:HtmlDocumentHandler.java

示例2: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
/** 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);

}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:53,代碼來源:HtmlDocumentHandler.java


注:本文中的javax.swing.text.MutableAttributeSet.getAttributeNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。