示例#1
0
 @Override
 protected void applyProperties(
     final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) {
   super.applyProperties(aElement, aConversionSettings);
   if (m_sValue != null) aElement.setAttribute(CHTMLAttributes.VALUE, m_sValue);
   if (m_bChecked) aElement.setAttribute(CHTMLAttributes.CHECKED, CHTMLAttributeValues.CHECKED);
 }
示例#2
0
 @Override
 protected void applyProperties(
     final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) {
   super.applyProperties(aElement, aConversionSettings);
   if (m_nHeight >= 0) aElement.setAttribute(CHTMLAttributes.HEIGHT, m_nHeight);
   if (m_nWidth >= 0) aElement.setAttribute(CHTMLAttributes.WIDTH, m_nWidth);
 }
示例#3
0
 @Override
 protected void applyProperties(
     final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) {
   super.applyProperties(aElement, aConversionSettings);
   if (StringHelper.hasText(m_sHref)) aElement.setAttribute(CHTMLAttributes.HREF, m_sHref);
   if (m_aTarget != null) aElement.setAttribute(CHTMLAttributes.TARGET, m_aTarget.getAttrValue());
 }
示例#4
0
 @Nonnull
 public IMicroDocument getAsDocument() {
   final IMicroDocument aDocument = new MicroDocument();
   final IMicroElement aElement = aDocument.appendElement(CFeed.XMLNS_ATOM, "feed");
   super.fillElement(aElement);
   for (final IFeedElement aEntry : m_aEntries) aElement.appendChild(aEntry.getAsElement("entry"));
   return aDocument;
 }
 @Override
 public void onCounter(final String sName, final IStatisticsHandlerCounter aHandler) {
   if (aHandler.getInvocationCount() > 0)
     m_eRoot
         .appendElement(StatisticsExporter.ELEMENT_COUNTER)
         .setAttribute(StatisticsExporter.ATTR_NAME, sName)
         .setAttribute(
             StatisticsExporter.ATTR_INVOCATIONCOUNT,
             Integer.toString(aHandler.getInvocationCount()))
         .setAttribute(StatisticsExporter.ATTR_COUNT, Long.toString(aHandler.getCount()));
 }
 @Override
 public void onCache(final String sName, final IStatisticsHandlerCache aHandler) {
   if (aHandler.getInvocationCount() > 0)
     m_eRoot
         .appendElement(StatisticsExporter.ELEMENT_CACHE)
         .setAttribute(StatisticsExporter.ATTR_NAME, sName)
         .setAttribute(
             StatisticsExporter.ATTR_INVOCATIONCOUNT,
             Integer.toString(aHandler.getInvocationCount()))
         .setAttribute(StatisticsExporter.ATTR_HITS, Integer.toString(aHandler.getHits()))
         .setAttribute(StatisticsExporter.ATTR_MISSES, Integer.toString(aHandler.getMisses()));
 }
 @Override
 public void onKeyedCounter(final String sName, final IStatisticsHandlerKeyedCounter aHandler) {
   if (aHandler.getInvocationCount() > 0) {
     final IMicroElement eKeyedCounter =
         m_eRoot
             .appendElement(StatisticsExporter.ELEMENT_KEYEDCOUNTER)
             .setAttribute(StatisticsExporter.ATTR_NAME, sName)
             .setAttribute(
                 StatisticsExporter.ATTR_INVOCATIONCOUNT,
                 Integer.toString(aHandler.getInvocationCount()));
     for (final String sKey : ContainerHelper.getSorted(aHandler.getAllKeys())) {
       eKeyedCounter
           .appendElement(StatisticsExporter.ELEMENT_KEY)
           .setAttribute(StatisticsExporter.ATTR_NAME, sKey)
           .setAttribute(
               StatisticsExporter.ATTR_INVOCATIONCOUNT,
               Integer.toString(aHandler.getInvocationCount(sKey)))
           .setAttribute(StatisticsExporter.ATTR_COUNT, Long.toString(aHandler.getCount(sKey)));
     }
   }
 }
示例#8
0
 /**
  * Interpret the passed XHTML fragment as HTML and retrieve a result container with all body
  * elements.
  *
  * @param sXHTML The XHTML text fragment. This fragment is parsed as an HTML body and may
  *     therefore not contain the <body> tag.
  * @return <code>null</code> if the passed text could not be interpreted as XHTML or if no body
  *     element was found, an {@link IMicroContainer} with all body children otherwise.
  */
 @Nullable
 public IMicroContainer unescapeXHTMLFragment(@Nullable final String sXHTML) {
   // Ensure that the content is surrounded by a single tag
   final IMicroDocument aDoc = parseXHTMLFragment(sXHTML);
   if (aDoc != null && aDoc.getDocumentElement() != null) {
     // Find "body" case insensitive
     final IMicroElement eBody =
         HCUtils.getFirstChildElement(aDoc.getDocumentElement(), EHTMLElement.BODY);
     if (eBody != null) {
       final IMicroContainer ret = new MicroContainer();
       if (eBody.hasChildren()) {
         // Make a copy of the list, because it is modified in
         // detachFromParent!
         for (final IMicroNode aChildNode : ContainerHelper.newList(eBody.getChildren()))
           ret.appendChild(aChildNode.detachFromParent());
       }
       return ret;
     }
   }
   return null;
 }
 @Override
 public void onTimer(final String sName, final IStatisticsHandlerTimer aHandler) {
   if (aHandler.getInvocationCount() > 0)
     m_eRoot
         .appendElement(StatisticsExporter.ELEMENT_TIMER)
         .setAttribute(StatisticsExporter.ATTR_NAME, sName)
         .setAttribute(
             StatisticsExporter.ATTR_INVOCATIONCOUNT,
             Integer.toString(aHandler.getInvocationCount()))
         .setAttribute(StatisticsExporter.ATTR_MIN, Long.toString(aHandler.getMin()))
         .setAttribute(StatisticsExporter.ATTR_AVERAGE, Long.toString(aHandler.getAverage()))
         .setAttribute(StatisticsExporter.ATTR_MAX, Long.toString(aHandler.getMax()))
         .setAttribute(StatisticsExporter.ATTR_SUM, aHandler.getSum().toString());
 }
 @Override
 public void onKeyedSize(final String sName, final IStatisticsHandlerKeyedSize aHandler) {
   if (aHandler.getInvocationCount() > 0) {
     final IMicroElement eKeyedSize =
         m_eRoot
             .appendElement(StatisticsExporter.ELEMENT_KEYEDSIZE)
             .setAttribute(StatisticsExporter.ATTR_NAME, sName)
             .setAttribute(
                 StatisticsExporter.ATTR_INVOCATIONCOUNT,
                 Integer.toString(aHandler.getInvocationCount()));
     for (final String sKey : ContainerHelper.getSorted(aHandler.getAllKeys())) {
       eKeyedSize
           .appendElement(StatisticsExporter.ELEMENT_KEY)
           .setAttribute(StatisticsExporter.ATTR_NAME, sKey)
           .setAttribute(
               StatisticsExporter.ATTR_INVOCATIONCOUNT,
               Integer.toString(aHandler.getInvocationCount(sKey)))
           .setAttribute(StatisticsExporter.ATTR_MIN, Long.toString(aHandler.getMin(sKey)))
           .setAttribute(StatisticsExporter.ATTR_AVERAGE, Long.toString(aHandler.getAverage(sKey)))
           .setAttribute(StatisticsExporter.ATTR_MAX, Long.toString(aHandler.getMax(sKey)))
           .setAttribute(StatisticsExporter.ATTR_SUM, aHandler.getSum(sKey).toString());
     }
   }
 }
示例#11
0
 public CSSFiles(@Nonnull final IReadableResource aFile) {
   final IMicroDocument aDoc = MicroReader.readMicroXML(aFile);
   if (aDoc != null) {
     final IMicroElement eRoot = aDoc.getDocumentElement();
     if (eRoot.getTagName().equals("list")) {
       // Old style
       s_aLogger.warn("CSS file " + aFile.getPath() + " is in old syntax");
       final List<String> aAllCSSFiles = new ArrayList<String>();
       if (XMLListHandler.readList(eRoot, aAllCSSFiles).isFailure())
         s_aLogger.error("Failed to read " + aFile.getPath());
       for (final String sCSS : aAllCSSFiles) addGlobalItem(null, sCSS, null);
     } else {
       // New style
       for (final IMicroElement eChild : eRoot.getAllChildElements("css")) {
         final String sCondComment = eChild.getAttribute("condcomment");
         final String sPath = eChild.getAttribute("path");
         if (StringHelper.hasNoText(sPath)) {
           s_aLogger.error("Found CSS item without a path in " + aFile.getPath());
           continue;
         }
         final String sMedia = eChild.getAttribute("media");
         // ESCA-JAVA0261:
         final Set<ECSSMedium> aMediaList = new LinkedHashSet<ECSSMedium>();
         if (sMedia != null)
           for (final String sMedium : RegExHelper.getSplitToArray(sMedia, ",\\s*")) {
             final ECSSMedium eMedium = ECSSMedium.getFromNameOrNull(sMedium);
             if (eMedium == null) {
               s_aLogger.warn(
                   "CSS item '"
                       + sPath
                       + "' in "
                       + aFile.getPath()
                       + " has an invalid medium '"
                       + sMedium
                       + "' - ignoring");
               continue;
             }
             aMediaList.add(eMedium);
           }
         addGlobalItem(sCondComment, sPath, aMediaList);
       }
     }
   }
 }
示例#12
0
 @Override
 protected void applyProperties(
     @Nonnull final IMicroElement aElement,
     @Nonnull final IHCConversionSettingsToNode aConversionSettings) {
   super.applyProperties(aElement, aConversionSettings);
   if (m_nWidth > 0) aElement.setAttribute(CHTMLAttributes.WIDTH, m_nWidth);
   if (m_nHeight > 0) aElement.setAttribute(CHTMLAttributes.HEIGHT, m_nHeight);
   if (StringHelper.hasText(m_sHSpace)) aElement.setAttribute(CHTMLAttributes.HSPACE, m_sHSpace);
   if (StringHelper.hasText(m_sVSpace)) aElement.setAttribute(CHTMLAttributes.VSPACE, m_sVSpace);
   if (m_eAlign != null) aElement.setAttribute(CHTMLAttributes.ALIGN, m_eAlign);
   if (StringHelper.hasText(m_sArchive))
     aElement.setAttribute(CHTMLAttributes.ARCHIVE, m_sArchive);
   if (StringHelper.hasText(m_sBorder)) aElement.setAttribute(CHTMLAttributes.BORDER, m_sBorder);
   if (StringHelper.hasText(m_sClassID))
     aElement.setAttribute(CHTMLAttributes.CLASSID, m_sClassID);
   if (m_aCodeBase != null)
     aElement.setAttribute(CHTMLAttributes.CODEBASE, m_aCodeBase.getAsString());
   if (m_aCodeType != null)
     aElement.setAttribute(CHTMLAttributes.CODETYPE, m_aCodeType.getAsString());
   if (m_aData != null) aElement.setAttribute(CHTMLAttributes.DATA, m_aData.getAsString());
   if (m_bDeclare) aElement.setAttribute(CHTMLAttributes.DECLARE, CHTMLAttributeValues.DECLARE);
   if (StringHelper.hasText(m_sName)) aElement.setAttribute(CHTMLAttributes.NAME, m_sName);
   if (StringHelper.hasText(m_sStandBy))
     aElement.setAttribute(CHTMLAttributes.STANDBY, m_sStandBy);
   if (m_aType != null) aElement.setAttribute(CHTMLAttributes.TYPE, m_aType.getAsString());
   if (StringHelper.hasText(m_sUseMap)) aElement.setAttribute(CHTMLAttributes.USEMAP, m_sUseMap);
 }
示例#13
0
 @Override
 public IMicroElement getAsElement(final String sElementName) {
   final IMicroElement aElement = super.getAsElement(sElementName);
   for (final IFeedElement aEntry : m_aEntries) aElement.appendChild(aEntry.getAsElement("entry"));
   return aElement;
 }