Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 @Nonnull
 public String getAsString() {
   String ret = "";
   if (StringHelper.hasText(m_sResourceID)) ret += m_sResourceID;
   if (m_nLineNumber != ILLEGAL_NUMBER) {
     if (m_nColumnNumber != ILLEGAL_NUMBER)
       ret += "(" + m_nLineNumber + ":" + m_nColumnNumber + ")";
     else ret += "(" + m_nLineNumber + ":?)";
   }
   if (StringHelper.hasText(m_sField)) {
     if (ret.length() > 0) ret += " @ ";
     ret += m_sField;
   }
   return ret;
 }
 @Nullable
 public static EMessageDigestAlgorithm getFromStringIgnoreCase(@Nullable final String sAlgorithm) {
   if (StringHelper.hasText(sAlgorithm))
     for (final EMessageDigestAlgorithm eMD : EMessageDigestAlgorithm.values())
       if (eMD.m_sAlgorithm.equalsIgnoreCase(sAlgorithm)) return eMD;
   return null;
 }
Ejemplo n.º 4
0
 public static void jsonEscape(@Nullable final String sInput, @Nonnull final StringBuilder aSB) {
   if (StringHelper.hasText(sInput)) {
     final char[] aInput = sInput.toCharArray();
     if (!StringHelper.containsAny(aInput, CHARS_TO_MASK)) aSB.append(sInput);
     else _escape(aInput, aSB);
   }
 }
Ejemplo n.º 5
0
 /**
  * Check whether the passed text looks like it contains XHTML code. This is a heuristic check only
  * and does not perform actual parsing!
  *
  * @param sText The text to check.
  * @return <code>true</code> if the text looks like HTML
  */
 public static boolean looksLikeXHTML(@Nullable final String sText) {
   // If the text contains an open angle bracket followed by a character that
   // we think of it as HTML
   // (?s) enables the "dotall" mode - see Pattern.DOTALL
   return StringHelper.hasText(sText)
       && RegExHelper.stringMatchesPattern("(?s).*<[a-zA-Z].+", sText);
 }
Ejemplo n.º 6
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());
 }
Ejemplo n.º 7
0
 public static void jsonEscape(
     @Nullable final String sInput, @Nonnull @WillNotClose final Writer aWriter)
     throws IOException {
   if (StringHelper.hasText(sInput)) {
     final char[] aInput = sInput.toCharArray();
     if (!StringHelper.containsAny(aInput, CHARS_TO_MASK)) aWriter.write(aInput, 0, aInput.length);
     else _escape(aInput, aWriter);
   }
 }
Ejemplo n.º 8
0
  /**
   * Create a new MockHttpSession.
   *
   * @param aServletContext the ServletContext that the session runs in
   * @param sID a unique identifier for this session
   */
  public MockHttpSession(
      @Nullable final ServletContext aServletContext, @Nullable final String sID) {
    m_aServletContext = aServletContext;
    m_sID = StringHelper.hasText(sID) ? sID : GlobalIDFactory.getNewStringID();

    final HttpSessionEvent aHSE = new HttpSessionEvent(this);
    for (final HttpSessionListener aListener : MockHttpListener.getAllHttpSessionListeners())
      aListener.sessionCreated(aHSE);
  }
Ejemplo n.º 9
0
  /**
   * Get the enum value with the passed name
   *
   * @param <ENUMTYPE> The enum type
   * @param aClass The enum class
   * @param sName The name to search
   * @param aDefault The default value to be returned, if the name was not found.
   * @return The default parameter if no enum item with the given name is present.
   */
  @Nullable
  public static <ENUMTYPE extends Enum<ENUMTYPE> & IHasName> ENUMTYPE getFromNameOrDefault(
      @Nonnull final Class<ENUMTYPE> aClass,
      @Nullable final String sName,
      @Nullable final ENUMTYPE aDefault) {
    ValueEnforcer.notNull(aClass, "Class");

    if (StringHelper.hasText(sName))
      for (final ENUMTYPE aElement : aClass.getEnumConstants())
        if (aElement.getName().equals(sName)) return aElement;
    return aDefault;
  }
Ejemplo n.º 10
0
 @Nonnull
 public HCTextNode prependText(@Nullable final String sText) {
   if (StringHelper.hasText(sText)) m_sText = sText + m_sText;
   return this;
 }
Ejemplo n.º 11
0
 @Override
 public boolean canConvertToNode(@Nonnull final IHCConversionSettingsToNode aConversionSettings) {
   return StringHelper.hasText(m_sHref) || m_aTarget != null;
 }