下面列出了javax.annotation.RegEx#com.helger.commons.annotation.Nonempty 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Nonnull
@Nonempty
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
aSettings.checkVersionRequirements (this);
final boolean bOptimizedOutput = aSettings.isOptimizedOutput ();
final StringBuilder aSB = new StringBuilder (":not(");
boolean bFirst = true;
for (final CSSSelector aNestedSelector : m_aNestedSelectors)
{
if (bFirst)
bFirst = false;
else
aSB.append (bOptimizedOutput ? "," : ", ");
aSB.append (aNestedSelector.getAsCSSString (aSettings, 0));
}
return aSB.append (')').toString ();
}
@Nonnull
@Nonempty
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
// Always ignore namespace rules?
if (!aSettings.isWriteNamespaceRules ())
return "";
final StringBuilder aSB = new StringBuilder ();
aSB.append ("@namespace ");
if (StringHelper.hasText (m_sPrefix))
aSB.append (m_sPrefix).append (' ');
if (StringHelper.hasText (m_sURL))
aSB.append (CSSURLHelper.getAsCSSURL (m_sURL, false));
else
aSB.append ("\"\"");
return aSB.append (';').append (aSettings.getNewLineString ()).toString ();
}
/**
* Create a common string to be used for unexpected rules.
*
* @param aCurrentToken
* The current token that caused an error. Never <code>null</code>.
* @param sRule
* The name of the rule. Always starts with a '@'. May neither be
* <code>null</code> nor empty.
* @param sMsg
* The custom error message. Neither <code>null</code> nor empty.
* @return The concatenated string with source location, rule and message. May
* neither be <code>null</code> nor empty.
*/
@Nonnull
@Nonempty
public static String createLoggingStringUnexpectedRule (@Nonnull final Token aCurrentToken,
@Nonnull @Nonempty final String sRule,
@Nonnull @Nonempty final String sMsg)
{
return "[" +
aCurrentToken.beginLine +
":" +
aCurrentToken.beginColumn +
"] Unexpected rule '" +
sRule +
"': " +
sMsg;
}
@Nonnull
@Nonempty
public static String createLoggingStringBrowserCompliantSkip (@Nullable final ParseException ex,
@Nonnull final Token aFromToken,
@Nonnull final Token aToToken)
{
String ret = "Browser compliant mode skipped CSS from [" +
aFromToken.beginLine +
":" +
aFromToken.beginColumn +
"] starting at token '" +
aFromToken.image +
"' until [" +
aToToken.endLine +
":" +
aToToken.endColumn +
"] to token '" +
aToToken.image +
"'";
if (ex != null)
ret += " (based on " + ex.getClass ().getName () + ": " + ex.getMessage () + ")";
return ret;
}
@Nonnull
public final XMLWriterSettings setIndentationString (@Nonnull @Nonempty final String sIndentationString)
{
m_sIndentationString = ValueEnforcer.notEmpty (sIndentationString, "IndentationString");
m_sIndentationStringToString = null;
return this;
}
/**
* Get all mime types that are associated to the extension of the specified
* filename.
*
* @param sFilename
* The filename to search. May neither be <code>null</code> nor empty.
* @return Never <code>null</code> but maybe empty set if no mime type is
* associated with the extension of the passed filename.
*/
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <String> getAllMimeTypeStringsForFilename (@Nonnull @Nonempty final String sFilename)
{
ValueEnforcer.notEmpty (sFilename, "Filename");
final String sExtension = FilenameHelper.getExtension (sFilename);
return getAllMimeTypeStringsForExtension (sExtension);
}
/**
* @return opacity part
*/
@Nonnull
@Nonempty
public String getOpacity ()
{
return m_sOpacity;
}
@Nonnull
@Nonempty
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
aSettings.checkVersionRequirements (this);
final StringBuilder aSB = new StringBuilder ();
aSB.append ('(').append (m_sFeature);
if (m_aValue != null)
aSB.append (CCSS.SEPARATOR_PROPERTY_VALUE).append (m_aValue.getAsCSSString (aSettings, nIndentLevel));
return aSB.append (')').toString ();
}
@Nonnull
default IMPLTYPE add (@Nonnull @Nonempty final String sName, @Nullable final String sValue)
{
// Ensure the parameter is kept - maybe without a value
add (new URLParameter (sName, sValue != null ? sValue : ""));
return thisAsT ();
}
@Nullable
public ICSSValue createSpecialValue (@Nonnull final ICSSProperty aProperty,
@Nonnull @Nonempty final String sValue,
final boolean bIsImportant)
{
return new CSSValueMultiProperty (aProperty.getProp (),
new ICSSProperty [] { aProperty,
aProperty.getClone (ECSSVendorPrefix.MOZILLA),
aProperty.getClone (ECSSVendorPrefix.WEBKIT),
aProperty.getClone (ECSSVendorPrefix.KHTML) },
sValue,
bIsImportant);
}
@Nonnull
@Nonempty
@Override
public String getYears (@CheckForSigned final int nYears)
{
// Use "abs" to ensure it is "1 year" and "-1 year"
return MathHelper.abs (nYears) == 1 ? nYears + " Jahr" : nYears + " Jahre";
}
/**
* Get the string representation of the version number but only major and
* minor version number.
*
* @return Never <code>null</code>.
*/
@Nonnull
@Nonempty
public String getAsStringMajorMinor ()
{
return m_nMajor + "." + m_nMinor;
}
public CSSPropertyEnumOrRect (@Nonnull final ECSSProperty eProp,
@Nullable final ECSSVendorPrefix eVendorPrefix,
@Nullable final ICSSPropertyCustomizer aCustomizer,
@Nonnull @Nonempty final String... aEnumValues)
{
super (eProp, eVendorPrefix, aCustomizer, aEnumValues);
}
/**
* @return The rule declaration string used in the CSS. Neither
* <code>null</code> nor empty. Always starting with <code>@</code>
* and ending with <code>viewport</code>.
*/
@Nonnull
@Nonempty
public String getDeclaration ()
{
return m_sDeclaration;
}
/**
* @return The property name including an eventually contained vendor prefix.
* Neither <code>null</code> nor empty.
* @since 3.9.0
*/
@Nonnull
@Nonempty
public String getPropertyName ()
{
return m_aProperty.getPropertyName ();
}
public CSSPropertyEnumOrColors (@Nonnull final ECSSProperty eProp,
@Nonnegative final int nMinNumbers,
@Nonnegative final int nMaxNumbers,
@Nonnull @Nonempty final String... aEnumValues)
{
this (eProp, (ICSSPropertyCustomizer) null, nMinNumbers, nMaxNumbers, aEnumValues);
}
@Override
@Nonnull
@Nonempty
public String getAsCSSString (@Nonnull final ICSSWriterSettings aSettings, @Nonnegative final int nIndentLevel)
{
final boolean bOptimizedOutput = aSettings.isOptimizedOutput ();
final StringBuilder aSB = new StringBuilder ();
final int nDeclCount = getDeclarationCount ();
if (nDeclCount == 0)
{
aSB.append (bOptimizedOutput ? "{}" : " {}");
}
else
{
if (nDeclCount == 1)
{
// A single declaration
aSB.append (bOptimizedOutput ? "{" : " { ");
aSB.append (super.getAsCSSString (aSettings, nIndentLevel));
aSB.append (bOptimizedOutput ? "}" : " }");
}
else
{
// More than one declaration
aSB.append (bOptimizedOutput ? "{" : " {" + aSettings.getNewLineString ());
aSB.append (super.getAsCSSString (aSettings, nIndentLevel));
if (!bOptimizedOutput)
aSB.append (aSettings.getIndent (nIndentLevel));
aSB.append ('}');
}
}
return aSB.toString ();
}
@Nonnull
public IMutableGraphRelation createRelation (@Nonnull @Nonempty final String sRelationID,
@Nonnull final String sFromNodeID,
@Nonnull final String sToNodeID)
{
final IMutableGraphNode aFromNode = getNodeOfID (sFromNodeID);
if (aFromNode == null)
throw new IllegalArgumentException ("Failed to resolve from node ID '" + sFromNodeID + "'");
final IMutableGraphNode aToNode = getNodeOfID (sToNodeID);
if (aToNode == null)
throw new IllegalArgumentException ("Failed to resolve to node ID '" + sToNodeID + "'");
return createRelation (sRelationID, aFromNode, aToNode);
}
@Nonnull
@Nonempty
@ReturnsMutableCopy
public ICommonsSet <MimeTypeWithSource> getAllMimeTypesWithSource ()
{
return m_aMimeTypes.getClone ();
}
/**
* @return The error message created by {@link LoggingCSSParseErrorHandler} as
* a convenience method. Neither <code>null</code> nor empty.
*/
@Nonnull
@Nonempty
public String getErrorMessage ()
{
return m_sErrorMessage;
}
public Result (@Nonnull @Nonempty final ICommonsList <N> aResultNodes, @Nonnegative final int nResultDistance)
{
ValueEnforcer.notEmpty (aResultNodes, "EesultNodes");
ValueEnforcer.isGE0 (nResultDistance, "Result Distance");
m_aResultNodes = aResultNodes;
m_nResultDistance = nResultDistance;
}
@Nonnull
public static IMutableStatisticsHandlerSize getSizeHandler (@Nonnull @Nonempty final String sName)
{
ValueEnforcer.notEmpty (sName, "Name");
StatisticsHandlerSize aHdl = s_aRWLockSize.readLockedGet ( () -> s_aHdlSize.get (sName));
if (aHdl == null)
{
aHdl = s_aRWLockSize.writeLockedGet ( () -> s_aHdlSize.computeIfAbsent (sName,
k -> new StatisticsHandlerSize ()));
}
return aHdl;
}
/**
* @param aFallbackCharset
* The charset to be used for reading the CSS file in case neither a
* <code>@charset</code> rule nor a BOM is present. May not be
* <code>null</code>.
* @return this
*/
@Nonnull
public CSSReaderSettings setFallbackCharset (@Nonnull @Nonempty final Charset aFallbackCharset)
{
ValueEnforcer.notNull (aFallbackCharset, "FallbackCharset");
m_aFallbackCharset = aFallbackCharset;
return this;
}
public static void setVendorEmail (@Nonnull @Nonempty final String sVendorEmail)
{
ValueEnforcer.notEmpty (sVendorEmail, "VendorEmail");
ValueEnforcer.isTrue (EmailAddressHelper.isValid (sVendorEmail), () -> "Illegal vendor email: " + sVendorEmail);
s_sVendorEmail = sVendorEmail;
s_sVendorEmailSuffix = StringHelper.getFromFirstIncl (sVendorEmail, '@');
}
@Nullable
public ICSSValue createSpecialValue (@Nonnull final ICSSProperty aProperty,
@Nonnull @Nonempty final String sValue,
final boolean bIsImportant)
{
return new CSSValueMultiProperty (aProperty.getProp (),
new ICSSProperty [] { aProperty,
aProperty.getClone (ECSSProperty._MOZ_BORDER_RADIUS_BOTTOMRIGHT),
aProperty.getClone (ECSSVendorPrefix.WEBKIT),
aProperty.getClone (ECSSVendorPrefix.KHTML) },
sValue,
bIsImportant);
}
@Nonnull
@Nonempty
@ReturnsMutableCopy
public ICommonsList <IWritableResourceProvider> getAllContainedWritingResourceProviders ()
{
return m_aWritableResourceProviders.getClone ();
}
@Nonnull
public static <T extends IRequestScope> T onRequestBegin (@Nonnull @Nonempty final String sScopeID,
@Nonnull @Nonempty final String sSessionID,
@Nonnull final BiFunction <? super String, ? super String, T> aFactory)
{
final T aRequestScope = aFactory.apply (sScopeID, sSessionID);
internalSetAndInitRequestScope (aRequestScope);
return aRequestScope;
}
public static void registerQueryBinding (@Nonnull @Nonempty final String sName,
@Nonnull final IPSQueryBinding aQueryBinding) throws SchematronBindException
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notNull (aQueryBinding, "QueryBinding");
s_aRWLock.writeLockedThrowing ( () -> {
if (s_aMap.containsKey (sName))
throw new SchematronBindException ("A queryBinding with the name '" + sName + "' is already registered!");
s_aMap.put (sName, aQueryBinding);
});
}
@Nonnull
public CSSExpressionMemberTermSimple setValue (@Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sValue, "Value");
m_sValue = sValue;
m_sOptimizedValue = CSSExpressionTermOptimizer.getOptimizedValue (sValue);
return this;
}
/**
* @return the 'unique' internal Option identifier. Either short or long
* option name.
* @see #getShortOpt()
* @see #getLongOpt()
*/
@Nonnull
@Nonempty
public final String getKey ()
{
// if 'opt' is null, then it is a 'long' option
return hasShortOpt () ? m_sShortOpt : m_sLongOpt;
}