public static boolean isDataAttrName (@Nullable final String sName) { return StringHelper.startsWith (sName, CHTMLAttributes.HTML5_PREFIX_DATA); }
/** * Check if the passed attribute name is an internal attribute. * * @param sAttributeName * The name of the attribute to check. May be <code>null</code>. * @return <code>true</code> if the passed attribute name is not * <code>null</code> and starts with the * {@link #SCOPE_ATTRIBUTE_PREFIX_INTERNAL} prefix. */ public static boolean isInternalAttribute (@Nullable final String sAttributeName) { return StringHelper.startsWith (sAttributeName, SCOPE_ATTRIBUTE_PREFIX_INTERNAL); } }
/** * Build a full resource location for the given path, prepending the resource * base path of this MockServletContext. * * @param sPath * the path as specified * @return the full resource path */ @Nonnull protected String getResourceLocation (@Nonnull final String sPath) { return StringHelper.startsWith (sPath, '/') ? m_sResourceBasePath + sPath : m_sResourceBasePath + "/" + sPath; }
@Nonnull public RequestDispatcher getRequestDispatcher (@Nonnull final String sPath) { if (!StringHelper.startsWith (sPath, '/')) throw new IllegalArgumentException ("RequestDispatcher path at ServletContext level must start with '/'"); return new MockRequestDispatcher (sPath); }
@Nonnull public MockHttpServletRequest setContextPath (@Nullable final String sContextPath) { if (StringHelper.hasText (sContextPath) && !StringHelper.startsWith (sContextPath, '/')) if (LOGGER.isErrorEnabled ()) LOGGER.error ("Illegal context path specified: '" + sContextPath + "'"); m_sContextPath = sContextPath; return this; }
@Nonnull public MockHttpServletRequest setServletPath (@Nullable final String sServletPath) { if (StringHelper.hasText (sServletPath) && !StringHelper.startsWith (sServletPath, '/')) if (LOGGER.isErrorEnabled ()) LOGGER.error ("ServletPath must be empty or start with a slash: '" + sServletPath + "'"); m_sServletPath = sServletPath; return this; }
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration) { return StringHelper.startsWith (sDeclaration, '@'); }
/** * Absolute paths are project relative files and therefore are relative to the * servlet context directory * * @param sURI * The String to check. May neither be <code>null</code> nor empty. * @return <code>true</code> if the URI starts with '/' */ public static final boolean isProjectRelativeURI (@Nonnull @Nonempty final String sURI) { return StringHelper.startsWith (sURI, '/'); }
@Nonnull private static String _getURIWithContext (@Nonnull final String sContextPath, @Nonnull final String sHRef) { if (StringHelper.hasText (sContextPath) && sHRef.startsWith (sContextPath)) { LOGGER.warn ("The passed href '" + sHRef + "' already contains the context path '" + sContextPath + "'!"); return sHRef; } // Always prefix with context path! final StringBuilder aSB = new StringBuilder (sContextPath); if (!StringHelper.startsWith (sHRef, '/')) aSB.append ('/'); return aSB.append (sHRef).toString (); }
public final void setContextPath (@Nullable final String sContextPath) { if (StringHelper.hasNoText (sContextPath)) m_sContextPath = ""; else if (StringHelper.startsWith (sContextPath, '/')) m_sContextPath = sContextPath; else m_sContextPath = '/' + sContextPath; ServletContextPathHolder.setServletContextPath (m_sContextPath); }
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration) { return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "viewport"); }
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration) { return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "keyframes"); }
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration) { return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "font-face"); }
@Nonnull public CSSPageMarginBlock setPageMarginSymbol (@Nonnull @Nonempty final String sPargeMarginSymbol) { ValueEnforcer.notEmpty (sPargeMarginSymbol, "PargeMarginSymbol"); ValueEnforcer.isTrue (StringHelper.startsWith (sPargeMarginSymbol, '@'), "Page margin symbol does not start with '@'!"); m_sPageMarginSymbol = sPargeMarginSymbol; return this; }
@Nonnull @Nonempty public static String getFullServerNameAndPath (@Nonnull final String sScheme, @Nonnull final String sServerName, final int nServerPort, @Nullable final String sPath, @Nullable final String sQueryString) { final StringBuilder aURL = getFullServerName (sScheme, sServerName, nServerPort); if (StringHelper.hasText (sPath)) { if (!StringHelper.startsWith (sPath, '/')) aURL.append ('/'); aURL.append (sPath); } if (StringHelper.hasText (sQueryString)) aURL.append (URLHelper.QUESTIONMARK).append (sQueryString); return aURL.toString (); }
@Nonnull public PhotonGlobalStatePerApp setServletPath (@Nonnull @Nonempty final String sServletPath) { ValueEnforcer.notEmpty (sServletPath, "ApplicationServletPath"); ValueEnforcer.isTrue (StringHelper.startsWith (sServletPath, '/'), "ApplicationServletPath must start with a slash"); ValueEnforcer.isFalse (StringHelper.endsWith (sServletPath, '/'), "ApplicationServletPath must end with a slash"); m_aRWLock.writeLocked ( () -> m_sServletPath = sServletPath); return this; }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { final EHTMLVersion eHTMLVersion = aConversionSettings.getHTMLVersion (); // Deprecation is checked for all elements _checkDeprecation (getClass (), getTagName (), eHTMLVersion); if (eHTMLVersion.isAtLeastHTML5 ()) { if (m_aCustomAttrs != null) for (final Map.Entry <String, String> aEntry : m_aCustomAttrs.entrySet ()) { final String sAttrName = aEntry.getKey (); // Link element often contains arbitrary attributes if (!StringHelper.startsWith (sAttrName, CHTMLAttributes.HTML5_PREFIX_DATA) && !StringHelper.startsWith (sAttrName, CHTMLAttributes.PREFIX_ARIA) && m_eElement != EHTMLElement.LINK) { HCConsistencyChecker.consistencyError ("Custom HTML5 attribute '" + sAttrName + "' does not start with one of the proposed prefixes '" + CHTMLAttributes.HTML5_PREFIX_DATA + "' or '" + CHTMLAttributes.PREFIX_ARIA + "'"); } } } }
/** * Set the user data path, relative to the URL context and relative to the * servlet context directory. * * @param sUserDataPath * The path to be set. May neither be <code>null</code> nor empty and * must start with a "/" character. */ public static void setUserDataPath (@Nonnull @Nonempty final String sUserDataPath) { ValueEnforcer.isTrue (StringHelper.getLength (sUserDataPath) >= 2, "userDataPath is too short"); ValueEnforcer.isTrue (StringHelper.startsWith (sUserDataPath, '/'), "userDataPath must start with a slash"); s_aRWLock.writeLocked ( () -> s_sUserDataPath = sUserDataPath); }
if (StringHelper.startsWith (sOrigValue, '[') && StringHelper.endsWith (sOrigValue, ']'))
@Nonnull public static SimpleURL getAsURLStatic (@Nonnull @Nonempty final String sURI) { ValueEnforcer.notEmpty (sURI, "URI"); SimpleURL ret; // If the URL is absolute, use it if (LinkHelper.hasKnownProtocol (sURI)) ret = new SimpleURL (sURI); else { // Absolute paths stays if (isProjectRelativeURI (sURI)) { // Just add the context ret = LinkHelper.getURLWithContext (sURI); } else { // It's relative and therefore streamed String sPrefix = LinkHelper.getStreamServletPath (); if (!StringHelper.startsWith (sURI, '/')) sPrefix += '/'; ret = LinkHelper.getURLWithContext (sPrefix + sURI); } } return ret; }