本文整理汇总了Java中com.helger.commons.CGlobal.BYTES_PER_KILOBYTE属性的典型用法代码示例。如果您正苦于以下问题:Java CGlobal.BYTES_PER_KILOBYTE属性的具体用法?Java CGlobal.BYTES_PER_KILOBYTE怎么用?Java CGlobal.BYTES_PER_KILOBYTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.helger.commons.CGlobal
的用法示例。
在下文中一共展示了CGlobal.BYTES_PER_KILOBYTE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNodeAsBytes
/**
* Convert the passed DOM node to an XML byte array using the provided XML
* writer settings.
*
* @param aNode
* The node to be converted to a byte array. May not be
* <code>null</code>.
* @param aSettings
* The XML writer settings to be used. May not be <code>null</code>.
* @return The byte array representation of the passed node.
* @since 8.6.3
*/
@Nullable
public static byte [] getNodeAsBytes (@Nonnull final Node aNode, @Nonnull final IXMLWriterSettings aSettings)
{
ValueEnforcer.notNull (aNode, "Node");
ValueEnforcer.notNull (aSettings, "Settings");
try (final NonBlockingByteArrayOutputStream aWriter = new NonBlockingByteArrayOutputStream (50 *
CGlobal.BYTES_PER_KILOBYTE))
{
// start serializing
if (writeToStream (aNode, aWriter, aSettings).isSuccess ())
return aWriter.toByteArray ();
}
catch (final Throwable t)
{
s_aLogger.error ("Error serializing DOM node with settings " + aSettings.toString (), t);
}
return null;
}
示例2: getNodeAsString
/**
* Convert the passed micro node to an XML string using the provided settings.
*
* @param aNode
* The node to be converted to a string. May not be <code>null</code> .
* @param aSettings
* The XML writer settings to use. May not be <code>null</code>.
* @return The string representation of the passed node.
*/
@Nullable
public static String getNodeAsString (@Nonnull final IMicroNode aNode, @Nonnull final IXMLWriterSettings aSettings)
{
ValueEnforcer.notNull (aNode, "Node");
ValueEnforcer.notNull (aSettings, "Settings");
try (final NonBlockingStringWriter aWriter = new NonBlockingStringWriter (50 * CGlobal.BYTES_PER_KILOBYTE))
{
// start serializing
if (writeToWriter (aNode, aWriter, aSettings).isSuccess ())
return aWriter.getAsString ();
}
catch (final Throwable t)
{
s_aLogger.error ("Error serializing MicroDOM with settings " + aSettings.toString (), t);
}
return null;
}
示例3: getNodeAsBytes
/**
* Convert the passed micro node to an XML byte array using the provided
* settings.
*
* @param aNode
* The node to be converted to a byte array. May not be
* <code>null</code> .
* @param aSettings
* The XML writer settings to use. May not be <code>null</code>.
* @return The byte array representation of the passed node.
* @since 8.6.3
*/
@Nullable
public static byte [] getNodeAsBytes (@Nonnull final IMicroNode aNode, @Nonnull final IXMLWriterSettings aSettings)
{
ValueEnforcer.notNull (aNode, "Node");
ValueEnforcer.notNull (aSettings, "Settings");
try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream (50 *
CGlobal.BYTES_PER_KILOBYTE))
{
// start serializing
if (writeToStream (aNode, aBAOS, aSettings).isSuccess ())
return aBAOS.toByteArray ();
}
catch (final Throwable t)
{
s_aLogger.error ("Error serializing MicroDOM with settings " + aSettings.toString (), t);
}
return null;
}
示例4: getAsMatching
@Nonnull
public String getAsMatching (final long nSize)
{
if (nSize >= CGlobal.BYTES_PER_PETABYTE)
return getAsPB (nSize);
if (nSize >= CGlobal.BYTES_PER_TERABYTE)
return getAsTB (nSize);
if (nSize >= CGlobal.BYTES_PER_GIGABYTE)
return getAsGB (nSize);
if (nSize >= CGlobal.BYTES_PER_MEGABYTE)
return getAsMB (nSize);
if (nSize >= CGlobal.BYTES_PER_KILOBYTE)
return getAsKB (nSize);
return _format (nSize) + B_SUFFIX;
}
示例5: canBeKeptInMemory
public static boolean canBeKeptInMemory (final long nBytes)
{
return nBytes <= 64 * CGlobal.BYTES_PER_KILOBYTE;
}