Java Code Examples for com.helger.commons.collection.ArrayHelper#getCopy()

The following examples show how to use com.helger.commons.collection.ArrayHelper#getCopy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MimeTypeParser.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @return A copy of the array with all TSpecial chars. Never
 *         <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public static char [] getAllTSpecialChars ()
{
  return ArrayHelper.getCopy (TSPECIAL);
}
 
Example 2
Source File: ByteBuffersInputStream.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @return A copy of the array with the byte buffers. Never <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public ByteBuffer [] getAllBuffers ()
{
  _checkClosed ();
  return ArrayHelper.getCopy (m_aBuffers);
}
 
Example 3
Source File: PasswordSalt.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Nonempty
@ReturnsMutableCopy
public byte [] getSaltBytes ()
{
  return ArrayHelper.getCopy (m_aBytes);
}
 
Example 4
Source File: ByteBufferOutputStream.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get everything as a big byte array, without altering the ByteBuffer. This
 * works only if the contained ByteBuffer has a backing array.
 *
 * @return The content of the buffer as a byte array. Never <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public byte [] getAsByteArray ()
{
  final byte [] aArray = m_aBuffer.array ();
  final int nOfs = m_aBuffer.arrayOffset ();
  final int nLength = m_aBuffer.position ();

  return ArrayHelper.getCopy (aArray, nOfs, nLength);
}
 
Example 5
Source File: ThreadDeadlockInfo.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @return The stack trace at the time the dead lock was found. May be
 *         <code>null</code> for certain system threads. Use
 *         <code>getThread ().getStackTrace ()</code> to retrieve the current
 *         stack trace.
 */
@Nullable
@ReturnsMutableCopy
public StackTraceElement [] getAllStackTraceElements ()
{
  return ArrayHelper.getCopy (m_aStackTrace);
}
 
Example 6
Source File: ThreadDeadlockInfo.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public ThreadDeadlockInfo (@Nonnull final ThreadInfo aThreadInfo,
                           @Nonnull final Thread aThread,
                           @Nullable final StackTraceElement [] aStackTrace)
{
  m_aThreadInfo = ValueEnforcer.notNull (aThreadInfo, "ThreadInfo");
  m_aThread = ValueEnforcer.notNull (aThread, "Thread");
  m_aStackTrace = ArrayHelper.getCopy (aStackTrace);
}
 
Example 7
Source File: HasTextWithArgs.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get all arguments from the constructor.
 *
 * @return a copy of all arguments. Neither <code>null</code> nor empty-
 */
@Nonnull
@Nonempty
@ReturnsMutableCopy
public Object [] getAllArgs ()
{
  return ArrayHelper.getCopy (m_aArgs);
}
 
Example 8
Source File: HasDisplayTextWithArgs.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get all arguments from the constructor.
 *
 * @return a copy of all arguments. Neither <code>null</code> nor empty-
 */
@Nonnull
@Nonempty
@ReturnsMutableCopy
public Object [] getAllArgs ()
{
  return ArrayHelper.getCopy (m_aArgs);
}
 
Example 9
Source File: DynamicHasErrorTextWithArgs.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get all arguments from the constructor.
 *
 * @return a copy of all arguments. Neither <code>null</code> nor empty-
 */
@Nonnull
@Nonempty
@ReturnsMutableCopy
public Object [] getAllArgs ()
{
  return ArrayHelper.getCopy (m_aArgs);
}
 
Example 10
Source File: PasswordSaltBCrypt.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Nonempty
@ReturnsMutableCopy
public byte [] getSaltBytes ()
{
  return ArrayHelper.getCopy (m_aBytes);
}
 
Example 11
Source File: ArrayEnumeration.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor iterating an array partially.
 *
 * @param aArray
 *        The array to be enumerated. May not be <code>null</code>.
 * @param nStartIndex
 *        The index of the first element to be enumerated.
 * @param nLength
 *        The maximum number of elements to be iterated.
 */
public ArrayEnumeration (@Nonnull final ELEMENTTYPE [] aArray,
                         @Nonnegative final int nStartIndex,
                         @Nonnegative final int nLength)
{
  ValueEnforcer.notNull (aArray, "Array");
  ValueEnforcer.isGE0 (nStartIndex, "StartIndex");
  ValueEnforcer.isGE0 (nLength, "Length");
  m_nIndex = 0;
  m_aArray = ArrayHelper.getCopy (aArray, nStartIndex, nLength);
}
 
Example 12
Source File: CSSDataURL.java    From ph-css with Apache License 2.0 4 votes vote down vote up
/**
 * Full constructor
 *
 * @param aMimeType
 *        The MIME type to be used. May not be <code>null</code>. If you don't
 *        know provide the default MIME type from
 *        {@link CSSDataURLHelper#DEFAULT_MIME_TYPE}.
 * @param bBase64Encoded
 *        <code>true</code> if the data URL String representation should be
 *        Base64 encoded, <code>false</code> if not. It is recommended to set
 *        this to <code>true</code> if you have binary data like images.
 * @param aContent
 *        The content of the data URL as a byte array. May not be
 *        <code>null</code> but may be empty. This content may not be Base64
 *        encoded!
 * @param aCharset
 *        The charset to be used to encode the String. May not be
 *        <code>null</code>. The default is
 *        {@link CSSDataURLHelper#DEFAULT_CHARSET}.
 * @param sContent
 *        The String representation of the content. It must match the byte
 *        array in the specified charset. If this parameter is
 *        <code>null</code> than the String content representation is lazily
 *        created in {@link #getContentAsString()}.
 */
public CSSDataURL (@Nonnull final IMimeType aMimeType,
                   final boolean bBase64Encoded,
                   @Nonnull final byte [] aContent,
                   @Nonnull final Charset aCharset,
                   @Nullable final String sContent)
{
  ValueEnforcer.notNull (aMimeType, "MimeType");
  ValueEnforcer.notNull (aContent, "Content");
  ValueEnforcer.notNull (aCharset, "Charset");

  // Check if a charset is contained in the MIME type and if it matches the
  // provided charset
  final Charset aMimeTypeCharset = MimeTypeHelper.getCharsetFromMimeType (aMimeType);
  if (aMimeTypeCharset == null)
  {
    // No charset found in MIME type
    if (!aCharset.equals (CSSDataURLHelper.DEFAULT_CHARSET))
    {
      // append charset only if it is not the default charset
      m_aMimeType = ((MimeType) aMimeType.getClone ()).addParameter (CMimeType.PARAMETER_NAME_CHARSET,
                                                                     aCharset.name ());
    }
    else
    {
      // Default charset provided
      m_aMimeType = aMimeType;
    }
  }
  else
  {
    // MIME type has a charset - check if it matches the passed one
    if (!aMimeTypeCharset.equals (aCharset))
      throw new IllegalArgumentException ("The provided charset '" +
                                          aCharset.name () +
                                          "' differs from the charset in the MIME type: '" +
                                          aMimeTypeCharset.name () +
                                          "'");
    m_aMimeType = aMimeType;
  }
  m_bBase64Encoded = bBase64Encoded;
  m_aContent = ArrayHelper.getCopy (aContent);
  m_aCharset = aCharset;
  m_sContent = sContent;
}
 
Example 13
Source File: LoadedKeyStore.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
/**
 * @return The error parameters. Never <code>null</code> in case of failure.
 *         Always <code>null</code> in case of success.
 */
@Nullable
public String [] getErrorParams ()
{
  return m_eError == null ? null : ArrayHelper.getCopy (m_aErrorParams);
}
 
Example 14
Source File: CSSDataURL.java    From ph-css with Apache License 2.0 3 votes vote down vote up
/**
 * Get a copy of all content bytes. No Base64 encoding is performed in this
 * method.
 *
 * @return A copy of the binary data of the data URL. Neither
 *         <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public byte [] getContentBytes ()
{
  return ArrayHelper.getCopy (m_aContent);
}
 
Example 15
Source File: ArrayIteratorShort.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * constructor with offset and length
 *
 * @param aArray
 *        Source array
 * @param nOfs
 *        Offset. Must be &ge; 0.
 * @param nLength
 *        Length. Must be &ge; 0.
 */
public ArrayIteratorShort (@Nonnull final short [] aArray,
                           @Nonnegative final int nOfs,
                           @Nonnegative final int nLength)
{
  ValueEnforcer.isArrayOfsLen (aArray, nOfs, nLength);
  m_aArray = ArrayHelper.getCopy (aArray, nOfs, nLength);
}
 
Example 16
Source File: ArrayIteratorDouble.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * constructor with offset and length
 *
 * @param aArray
 *        Source array
 * @param nOfs
 *        Offset. Must be &ge; 0.
 * @param nLength
 *        Length. Must be &ge; 0.
 */
public ArrayIteratorDouble (@Nonnull final double [] aArray,
                            @Nonnegative final int nOfs,
                            @Nonnegative final int nLength)
{
  ValueEnforcer.isArrayOfsLen (aArray, nOfs, nLength);
  m_aArray = ArrayHelper.getCopy (aArray, nOfs, nLength);
}
 
Example 17
Source File: ArrayIterator.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Private constructor with offset and length
 *
 * @param aArray
 *        Source array
 * @param nOfs
 *        Offset. Must be &ge; 0.
 * @param nLength
 *        Length. Must be &ge; 0.
 */
public ArrayIterator (@Nonnull final ELEMENTTYPE [] aArray,
                      @Nonnegative final int nOfs,
                      @Nonnegative final int nLength)
{
  ValueEnforcer.isArrayOfsLen (aArray, nOfs, nLength);

  m_aArray = ArrayHelper.getCopy (aArray, nOfs, nLength);
}
 
Example 18
Source File: ByteArrayWrapper.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Wrap the passed byte array or just parts of it.
 *
 * @param aBytes
 *        The byte array to be wrapped. May not be <code>null</code>.
 * @param nOfs
 *        Offset. Must be &ge; 0.
 * @param nLength
 *        Length. Must be &ge; 0.
 * @param bCopyNeeded
 *        <code>true</code> to copy it, <code>false</code> to reuse the
 *        instance.
 */
public ByteArrayWrapper (@Nonnull final byte [] aBytes,
                         @Nonnegative final int nOfs,
                         @Nonnegative final int nLength,
                         final boolean bCopyNeeded)
{
  ValueEnforcer.isArrayOfsLen (aBytes, nOfs, nLength);
  m_aBytes = bCopyNeeded ? ArrayHelper.getCopy (aBytes, nOfs, nLength) : aBytes;
  m_nOffset = bCopyNeeded ? 0 : nOfs;
  m_nLength = nLength;
  m_bIsCopy = bCopyNeeded;
}
 
Example 19
Source File: ByteBuffersInputStream.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor
 *
 * @param aBuffers
 *        Array of {@link ByteBuffer}. May neither be <code>null</code> nor
 *        empty and may not contain <code>null</code> elements.
 */
public ByteBuffersInputStream (@Nonnull @Nonempty final ByteBuffer... aBuffers)
{
  ValueEnforcer.notEmpty (aBuffers, "Buffers");

  m_aBuffers = ArrayHelper.getCopy (aBuffers);
}
 
Example 20
Source File: Base64OutputStream.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Set the newline bytes to be used, so that "\r\n" can be used instead of the
 * default "\n"
 *
 * @param aNewLineBytes
 *        The newline bytes to be used. May neither be <code>null</code> nor
 *        empty.
 * @since 9.3.4
 */
public void setNewLineBytes (@Nonnull @Nonempty final byte [] aNewLineBytes)
{
  ValueEnforcer.notEmpty (aNewLineBytes, "NewLineBytes");
  m_aNewLineBytes = ArrayHelper.getCopy (aNewLineBytes);
}