/** * @param ptgs may be <c>null</c> * @return encoded size of the formula */ private static int GetFormulaSize(Ptg[] ptgs) { if (ptgs == null) { return(0); } return(Ptg.GetEncodedSize(ptgs)); }
/** * Creates a {@link Formula} object from a supplied {@link Ptg} array. * Handles <code>null</code>s OK. * @param ptgs may be <code>null</code> * @return Never <code>null</code> (Possibly empty if the supplied <c>ptgs</c> is <code>null</code>) */ public static Formula Create(Ptg[] ptgs) { if (ptgs == null || ptgs.Length < 1) { return(EMPTY); } int totalSize = Ptg.GetEncodedSize(ptgs); byte[] encodedData = new byte[totalSize]; Ptg.SerializePtgs(ptgs, encodedData, 0); int encodedTokenLen = Ptg.GetEncodedSizeWithoutArrayData(ptgs); return(new Formula(encodedData, encodedTokenLen)); }