class PDLineDashPattern implements COSObjectable
{
    private final int phase;
    private final float[] array;

    /**
     * Creates a new line dash pattern, with no dashes and a phase of 0.
     */
    public PDLineDashPattern()
    {
        array = new float[] { };
        phase = 0;
    }

    /**
     * Creates a new line dash pattern from a dash array and phase.
     * @param array the dash array
     * @param phase the phase
     */
    public PDLineDashPattern(COSArray array, int phase)
    {
        this.array = array.toFloatArray();
        // PDF 2.0 specification, 8.4.3.6 Line dash pattern:
        // "If the dash phase is negative, it shall be incremented by twice the sum of all
        // lengths in the dash array until it is positive"
        if (phase < 0)
        {
            float sum2 = 0;
            for (float f : this.array)
            {
                sum2 += f; 
            }
            sum2 *= 2;
            if (sum2 > 0)
            {
                phase += (-phase < sum2) ? sum2 : (Math.floor(-phase / sum2) + 1) * sum2;
            }
            else
            {
                phase = 0;
            }
        }
        this.phase = phase;
    }

    @Override
    public COSBase getCOSObject()
    {<FILL_FUNCTION_BODY>}

    /**
     * Returns the dash phase.
     * This specifies the distance into the dash pattern at which to start the dash.
     * @return the dash phase
     */
    public int getPhase()
    {
        return phase;
    }

    /**
     * Returns the dash array.
     * @return the dash array, never null.
     */
    public float[] getDashArray()
    {
        return array.clone();
    }

    @Override
    public String toString()
    {
        return "PDLineDashPattern{array=" + Arrays.toString(array) + ", phase=" + phase + "}";
    }
}

        COSArray cos = new COSArray();
        cos.add(COSArray.of(array));
        cos.add(COSInteger.get(phase));
        return cos;
    
<no_super_class>