Example #1
0
        public virtual void testAudit()
        {
            JDFAuditPool ap = n.getAuditPool();

            Assert.IsNotNull(ap);
            JDFCreated crea  = (JDFCreated)ap.getAudit(0, EnumAuditType.Created, null, null);
            string     agent = crea.getAgentName();

            Assert.IsNotNull(agent);
            string author = crea.getAuthor();

            Assert.IsNotNull(author);

            n.fixVersion(EnumVersion.Version_1_1);
            author = crea.getAuthor();
            Assert.AreEqual(agent, StringUtil.token(author, 1, "_|_"));
            Assert.IsTrue(author.StartsWith(agent));
            string agent2 = crea.getAgentName();

            Assert.AreEqual("", agent2);

            n.fixVersion(EnumVersion.Version_1_3);
            author = crea.getAuthor();
            Assert.AreEqual(-1, author.IndexOf("_|_"));
            agent2 = crea.getAgentName();
            Assert.AreEqual(agent, agent2);

            n.fixVersion(EnumVersion.Version_1_2);
            author = crea.getAuthor();
            Assert.AreEqual(-1, author.IndexOf("_|_"));
            agent2 = crea.getAgentName();
            Assert.AreEqual(agent, agent2);
        }
Example #2
0
        //
        //	 * // Element getter / setter
        //
        //
        //	 * (non-Javadoc)
        //	 *
        //	 * @see
        //	 * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java
        //	 * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue)
        //
        public override void addValue(string @value, EnumFitsValue testlists)
        {
            if (fitsValue(@value, testlists))
            {
                return;
            }

            if (!StringUtil.isNumber(@value))
            {
                return;
            }
            double d = StringUtil.parseDouble(@value, 0);

            if (testlists == null || EnumFitsValue.Allowed.Equals(testlists))
            {
                JDFNumberRangeList list = getAllowedValueList();
                if (list == null)
                {
                    list = new JDFNumberRangeList();
                }
                list.Append(d);
                setAllowedValueList(list);
            }
            if (testlists == null || EnumFitsValue.Present.Equals(testlists))
            {
                JDFNumberRangeList list = getPresentValueList();
                if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST))
                {
                    list = new JDFNumberRangeList();
                }
                list.Append(d);
                setPresentValueList(list);
            }
        }
Example #3
0
        ///
        ///	 <summary> * Set the Name and RawName attributes to the value given in pName The value
        ///	 * in Name uses the default encoding
        ///	 *  </summary>
        ///	 * <param name="char">[] cName the 8 bit string to set the name to </param>
        ///
        public virtual void set8BitNames(byte[] cName)
        {
            string rawName = StringUtil.setHexBinaryBytes(cName, -1);

            setRawName(rawName);
            setName(Encoding.Default.GetString(cName));
        }
Example #4
0
        ///
        ///	 <summary> * setString - parse the given string and set the integer ranges
        ///	 *  </summary>
        ///	 * <param name="s"> the given string
        ///	 *  </param>
        ///	 * <exception cref="FormatException"> - if the String has not a valid format </exception>
        ///
        public virtual void setString(string s)
        {
            rangeList.Clear();
            if (s == null || s.Equals(JDFConstants.EMPTYSTRING))
            {
                return;
            }
            if (s.IndexOf(JDFConstants.TILDE) == 0 || s.LastIndexOf(JDFConstants.TILDE) == (s.Length - 1))
            {
                throw new FormatException("JDFIntegerRangeList::SetString: Illegal string " + s);
            }
            string  zappedWS = StringUtil.zappTokenWS(s, "~");
            VString vs       = new VString(StringUtil.tokenize(zappedWS, " \t", false));

            for (int i = 0; i < vs.Count; i++)
            {
                string str = vs[i];
                try
                {
                    JDFIntegerRange ir = new JDFIntegerRange(str);
                    rangeList.Add(ir);
                }
                catch (FormatException)
                {
                    throw new FormatException("JDFIntegerRangeList::SetString: Illegal string " + s);
                }
            }
        }
Example #5
0
        public void testSeparationList()
        {
            JDFDoc          doc     = new JDFDoc("JDF");
            JDFNode         root    = doc.getJDFRoot();
            JDFResourcePool resPool = root.getCreateResourcePool();
            KElement        kElem   = resPool.appendResource(ElementName.COLORANTCONTROL, null, null);

            Assert.IsTrue(kElem is JDFColorantControl);
            JDFColorantControl cc   = ((JDFColorantControl)kElem);
            JDFSeparationList  co   = cc.appendColorantOrder();
            VString            seps = new VString(StringUtil.tokenize("Cyan Magenta Yellow Black", " ", false));

            co.setSeparations(seps);
            CollectionAssert.AreEqual(co.getSeparations(), seps);
            VElement vSepSpec = co.getChildElementVector(ElementName.SEPARATIONSPEC, null, null, true, 0, true);

            Assert.AreEqual(seps.Count, vSepSpec.Count);
            for (int i = 0; i < vSepSpec.Count; i++)
            {
                Assert.IsFalse(vSepSpec.item(i).hasAttribute(AttributeName.CLASS));
                Assert.IsFalse(vSepSpec.item(i) is JDFResource);
            }

            Assert.AreEqual("Cyan", co.getSeparation(0));
            co.removeSeparation("Magenta");
            Assert.AreEqual("Cyan", co.getSeparation(0));
            Assert.AreEqual("Yellow", co.getSeparation(1));
            Assert.AreEqual("Black", co.getSeparation(2));
            Assert.IsNull(co.getSeparation(3));
        }
Example #6
0
        ///
        ///	 <summary> * Formats a String into a string.
        ///	 *  </summary>
        ///	 * <param name="x"> String value to format </param>
        ///	 * <returns> Resulting string </returns>
        ///
        public virtual string tostr(string x)
        {
            if (type != 's')
            {
                if (StringUtil.isInteger(x))
                {
                    return(tostr(StringUtil.parseInt(x, 0)));
                }
                if (StringUtil.isNumber(x))
                {
                    return(tostr(StringUtil.parseDouble(x, 0)));
                }
                // no more choices, gotta go..
                throw new ArgumentException();
            }

            output.init(Math.Max(width, 1));

            if (prec >= 0)
            {
                output.append(x.Substring(0, prec));
            }
            else
            {
                output.append(x);
            }

            return(pad());
        }
Example #7
0
        ///
        ///	 <summary> * set the phone number of this, if this is a valid phone url, "tel:" or
        ///	 * "fax:" is prepended, if it is not yet there
        ///	 *  </summary>
        ///	 * <param name="phone">
        ///	 *            the phone number string </param>
        ///	 * <param name="replaceForBlank">
        ///	 *            the replacement char for non-leading blanks , typically "." or
        ///	 *            null are a good idea </param>
        ///	 * <param name="channelType">
        ///	 *            the channelType - must be either Fax or Phone </param>
        ///	 * <exception cref="IllegalArgumentException">
        ///	 *             if phone is not a valid phone number
        ///	 *  </exception>
        ///
        public virtual void setPhoneNumber(string phone, string replaceForBlank, EnumChannelType channelType)
        {
            string phoneLocal = phone;

            if (!EnumChannelType.Fax.Equals(channelType) && !EnumChannelType.Phone.Equals(channelType))
            {
                throw new ArgumentException("illegal channelType: " + channelType);
            }

            if (phoneLocal != null)
            {
                phoneLocal = phoneLocal.Trim();
            }

            phoneLocal = StringUtil.replaceCharSet(phoneLocal, " ", replaceForBlank, 0);
            if (phoneLocal == null || !StringUtil.matches(phoneLocal, JDFConstants.REGEXP_PHONE))
            {
                throw new ArgumentException("illegal phone number:" + phoneLocal);
            }

            setChannelType(channelType);
            if (!phoneLocal.ToLower().StartsWith(TEL))
            {
                phoneLocal = TEL + phoneLocal;
            }

            setLocator(phoneLocal);
        }
Example #8
0
            ///
            ///		 <summary> * get the sum of all matching AmountPool/PartAmount/@attName as a double PartAmounts match if all attributes
            ///		 * match those in PartAmount, i.e. mPart is a submap of the searche PartAmount elements
            ///		 *
            ///		 *  </summary>
            ///		 * <param name="attName"> the Attribute name , e.g Amount, ActualAmount </param>
            ///		 * <param name="mPart"> </param>
            ///		 * <returns> double - the element </returns>
            ///		 * <exception cref="JDFException"> if the element can not be cast to double </exception>
            ///
            public static double getAmountPoolDouble(IAmountPoolContainer poolParent, string attName, JDFAttributeMap mPart)
            {
                double d = 0;

                int           n      = 0;
                bool          bFound = false;
                JDFAmountPool ap     = poolParent.getAmountPool();

                while (true)
                {
                    string w = getAmountPoolAttribute(poolParent, attName, null, mPart, n);
                    if (isWildCard(w))
                    {
                        if (ap == null || ap.getPartAmount(mPart, n) == null)
                        {
                            return(bFound ? d : -1);
                        }

                        n++;
                        continue;
                    }

                    double dd = StringUtil.parseDouble(w, -1.234567);
                    if (dd == -1.234567)
                    {
                        throw new JDFException("JDFResourceLink.getAmountPoolDouble: Attribute " + attName + " has an invalid value");
                    }

                    d     += dd;
                    bFound = true;
                    n++;
                }
            }
Example #9
0
            ///
            ///		 * <param name="node"> </param>
            ///		 * <returns> true if it matches </returns>
            ///
            private bool matchesNode(JDFNode node)
            {
                if (node == null)
                {
                    return(false);
                }
                bool   bMatch = true;
                string jobID  = StringUtil.getNonEmpty(enclosingInstance.getJobID());

                if (jobID != null)
                {
                    bMatch = jobID.Equals(node.getJobID(true));
                }
                if (!bMatch)
                {
                    return(false);
                }
                string jobPartID = StringUtil.getNonEmpty(enclosingInstance.getJobPartID());

                if (jobPartID != null)
                {
                    bMatch = jobPartID.Equals(node.getJobPartID(true));
                }
                return(bMatch);
            }
Example #10
0
            ///
            ///		 <summary> * Method getAmountDouble
            ///		 *  </summary>
            ///		 * <param name="amParts"> </param>
            ///		 * <param name="strAttributeName">
            ///		 *  </param>
            ///		 * <returns> the sum of all matching amounts </returns>
            ///
            public virtual double getAmountDouble(JDFAttributeMap amParts, string strAttributeName)
            {
                double dValue            = -1.0;
                List <JDFPartAmount> lpa = null;

                TryGetValue(amParts, out lpa);

                if (lpa != null)
                {
                    double dTmp    = 0.0;
                    bool   isFound = false;
                    foreach (JDFPartAmount pa in lpa)
                    {
                        string strValue = pa.getAttribute(strAttributeName, null, null);
                        if (strValue != null)
                        {
                            double dAdd = StringUtil.parseDouble(strValue, -1.0);
                            if (dAdd >= 0.0)
                            {
                                dTmp   += dAdd;
                                isFound = true;
                            }
                        }
                    }

                    if (isFound)
                    {
                        dValue = dTmp;
                    }
                }

                return(dValue);
            }
Example #11
0
        ///
        ///	 <summary> * Create or modify a PhaseTime Audit and fill it If the phase is identical to the prior phase that has been set,
        ///	 * the existing PhaseTime is modified otherwise an existing phaseTime is closed and a new phaseTime is appended
        ///	 * Phasetime elements with different Parts are treated independently
        ///	 *  </summary>
        ///	 * <param name="status"> the node status at this time </param>
        ///	 * <param name="statusDetails"> details of this status </param>
        ///	 * <param name="vmParts"> defines a vector of map of parts for which the PhaseTime is valid </param>
        ///	 * <param name="employees"> Vector of employees that are currently registered for this job </param>
        ///	 * <returns> JDFPhaseTime the newly created PhaseTime audit
        ///	 *
        ///	 *         default: SetPhase(status, null,null,null) </returns>
        ///
        public virtual JDFPhaseTime setPhase(EnumNodeStatus status, string statusDetails, VJDFAttributeMap vmParts, VElement employees)
        {
            string statusDetailsLocal = statusDetails;

            JDFPhaseTime pt = getLastPhase(vmParts, null);

            statusDetailsLocal = StringUtil.getNonEmpty(statusDetailsLocal);
            bool     bChanged    = false;
            VElement ptEmployees = pt == null ? new VElement() : pt.getChildElementVector(ElementName.EMPLOYEE, null);

            if (pt == null)
            {
                bChanged = true;
            }
            else if (!ContainerUtil.Equals(pt.getStatus(), status) || !ContainerUtil.Equals(statusDetailsLocal, pt.getAttribute(AttributeName.STATUSDETAILS, null, null)) || !ptEmployees.isEqual(employees))
            {
                pt.setEnd(new JDFDate());
                bChanged = true;
            }
            if (bChanged)
            {
                pt = addPhaseTime(status, null, vmParts);
                pt.setStatusDetails(statusDetailsLocal);
                pt.copyElements(employees, null);
            }
            return(pt);
        }
Example #12
0
        ///
        ///	 <summary> * sets the firstame to value and also prepends firstName to value in case
        ///	 * descriptivename is either FirstName or empty/null
        ///	 *  </summary>
        ///	 * <param name="firstName">
        ///	 *            the family name to set </param>
        ///
        public override void setFirstName(string firstName)
        {
            string oldName = getAttribute(AttributeName.FIRSTNAME, null, null);

            base.setFirstName(firstName);
            if (firstName == null)
            {
                return;
            }
            string descName = getDescriptiveName();

            if (descName == null || descName.Equals(""))
            {
                setDescriptiveName(firstName);
            }
            else if (descName.Equals(getFamilyName()))
            {
                setDescriptiveName(firstName + " " + getFamilyName());
            }
            else if (oldName != null && descName.StartsWith(oldName))
            {
                descName = StringUtil.replaceString(descName, oldName, firstName);
                setDescriptiveName(descName);
            }
        }
Example #13
0
        public virtual void testadd()
        {
            VString v = new VString();

            v.Add(EnumType.AdhesiveBinding);
            Assert.AreEqual(EnumType.AdhesiveBinding.getName(), StringUtil.setvString(v, " ", null, null));
        }
Example #14
0
        ///
        ///	 <summary> * check whether the partition values match
        ///	 *  </summary>
        ///	 * <param name="key"> the partition key </param>
        ///	 * <param name="resourceValue"> the value of key in the resource </param>
        ///	 * <param name="linkValue"> the value of key in the part element or ref </param>
        ///	 * <returns> boolean: true if linkValue matches the value or list in resourceValue
        ///	 *  </returns>
        ///
        public static bool matchesPart(string key, string resourceValue, string linkValue)
        {
            EnumPartIDKey eKey = EnumPartIDKey.getEnum(key);

            if (eKey == null)
            {
                return(resourceValue.Equals(linkValue));
            }
            bool b;

            // EnumPartIDKey.PartVersion.equals(eKey)
            if (EnumPartIDKey.DocTags.Equals(eKey) || EnumPartIDKey.ItemNames.Equals(eKey) || EnumPartIDKey.PageTags.Equals(eKey) || EnumPartIDKey.RunTags.Equals(eKey) || EnumPartIDKey.SetTags.Equals(eKey))
            {
                b = StringUtil.matchesAttribute(linkValue, resourceValue, AttributeInfo.EnumAttributeType.NMTOKENS);
            }

            else if (EnumPartIDKey.DocCopies.Equals(eKey) || EnumPartIDKey.DocIndex.Equals(eKey) || EnumPartIDKey.DocRunIndex.Equals(eKey) || EnumPartIDKey.DocSheetIndex.Equals(eKey) || EnumPartIDKey.LayerIDs.Equals(eKey) || EnumPartIDKey.PageNumber.Equals(eKey) || EnumPartIDKey.RunIndex.Equals(eKey) || EnumPartIDKey.SectionIndex.Equals(eKey) || EnumPartIDKey.SetIndex.Equals(eKey) || EnumPartIDKey.SetRunIndex.Equals(eKey) || EnumPartIDKey.SetSheetIndex.Equals(eKey) || EnumPartIDKey.SheetIndex.Equals(eKey))
            {
                b = StringUtil.matchesAttribute(linkValue, resourceValue, AttributeInfo.EnumAttributeType.IntegerRangeList);
            }

            else
            {
                b = resourceValue.Equals(linkValue);
            }
            return(b);
        }
Example #15
0
        ///
        ///	 <summary> * setString - parse the given string and set the duration range list
        ///	 *  </summary>
        ///	 * <param name="s"> the given string
        ///	 *  </param>
        ///	 * <exception cref="FormatException"> - if the String has not a valid format </exception>
        ///
        public virtual void setString(string s)
        {
            if (s.IndexOf(JDFConstants.TILDE) == 0 || s.LastIndexOf(JDFConstants.TILDE) == (s.Length - 1))
            {
                throw new FormatException("JDFDateTimeRangeList::SetString: Illegal string " + s);
            }
            string  zappedWS = StringUtil.zappTokenWS(s, "~");
            VString v        = new VString(StringUtil.tokenize(zappedWS, " \t", false));
            VString vs       = new VString(v);

            rangeList.Clear();
            for (int i = 0; i < vs.Count; i++)
            {
                string str = vs[i];
                try
                {
                    JDFDateTimeRange dr = new JDFDateTimeRange(str);
                    rangeList.Add(dr);
                }
                catch (FormatException)
                {
                    throw new FormatException("JDFDateTimeRangeList::SetString: Illegal string " + s);
                }
            }
        }
Example #16
0
 ///
 ///	 <summary> * fitsRegExp - checks whether <code>str</code> matches the RegExp specified
 ///	 * for this Evaluation
 ///	 *  </summary>
 ///	 * <param name="str">
 ///	 *            string to test </param>
 ///	 * <returns> boolean - true, if <code>str</code> matches the RegExp or if no
 ///	 *         RegExp is specified </returns>
 ///
 private bool fitsRegExp(string str)
 {
     if (!hasAttribute(AttributeName.REGEXP))
     {
         return(true); // if RegExp is not specified return true
     }
     return(StringUtil.matches(str, getRegExp()));
 }
Example #17
0
 // **************************************** Methods
 // *********************************************
 ///
 ///	 <summary> * toString
 ///	 *  </summary>
 ///	 * <returns> String </returns>
 ///
 public override string ToString()
 {
     if (Left == Right)
     {
         return(StringUtil.formatInteger(Right));
     }
     return(StringUtil.formatInteger(Left) + " ~ " + StringUtil.formatInteger(Right));
 }
Example #18
0
        ///
        ///     <summary> * simulate execution of this node
        ///     * the internal node will be modified to reflect the excution </summary>
        ///
        public override void execute(VJDFAttributeMap vNodeMap, bool bOutAvail, bool bFirst)
        {
            JDFComment c = theExpandedNode.appendComment();

            c.setName("OperatorText");
            c.setText(StringUtil.getRandomString());

            base.execute(vNodeMap, bOutAvail, bFirst);
        }
Example #19
0
        ///
        ///	 <summary> * fitsRegExp - checks whether <code>str</code> matches the RegExp specified
        ///	 * for this Evaluation
        ///	 *  </summary>
        ///	 * <param name="str">
        ///	 *            string to test </param>
        ///	 * <returns> boolean - true, if <code>str</code> matches RegExp or if RegExp
        ///	 *         is not specified </returns>
        ///
        private bool fitsRegExp(string str)
        {
            if (!hasAttribute(AttributeName.REGEXP))
            {
                return(true);
            }

            return(StringUtil.matches(str, getRegExp()));
        }
Example #20
0
        public virtual void setPresentValueList(VString vs)
        {
            string s = JDFConstants.EMPTYSTRING;

            if (vs != null)
            {
                s = StringUtil.setvString(vs, " ", null, null);
            }
            setAttribute(AttributeName.PRESENTVALUELIST, s);
        }
Example #21
0
        public virtual void testSort()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("c");
            v.Add("b");
            v.Sort();
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
        }
Example #22
0
        public virtual void testGetAllString()
        {
            VString v = new VString();

            v.appendUnique("a");
            v.appendUnique("b");
            v.appendUnique("c");
            v.appendUnique("c");
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
        }
Example #23
0
        ///
        ///	 <summary> * Gets integer attribute MaxOccurs
        ///	 *  </summary>
        ///	 * <returns> int: the attribute value </returns>
        ///
        public virtual int getMaxOccurs()
        {
            string s = getAttribute(AttributeName.MAXOCCURS, null, null);

            if (JDFConstants.UNBOUNDED.Equals(s)) // legacy support
            {
                return(int.MaxValue);
            }
            return(StringUtil.parseInt(s, 1));
        }
Example #24
0
        public virtual void testSetElementAt()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("b");
            v.Add("c");
            v.Add("c");
            v.Add("e");
            v[3] = "d";
            Assert.AreEqual("a b c d e", StringUtil.setvString(v, " ", null, null));
        }
Example #25
0
        public void testActualColorName()
        {
            colParams.setXMLComment("Note that all Strings in ColorantParams etc. use Color/@Name, NOT Color/@ActualColorName");
            colParams.setSeparations(new VString("Spot1,BlackText", ","));
            colControl.setXMLComment("Simple colorantcontrol from MIS: CMYK + 1 spot+ 1 black text version; knows no more");
            d.write2File(sm_dirTestDataTemp + "ActualColorName_MIS.jdf", 2, false);

            colControl.setXMLComment("ColorantControl after prepress has correctly set ActualColorName based on pdl content");
            JDFColor co = colPool.appendColorWithName("Black", null);

            co.setXMLComment("Color that maps the predefined separation Black\n" + "ActualColorName is the new attribute that replaces ExposedMedia/@DescriptiveName as the \"Main\" PDL color");
            co.setCMYK(new JDFCMYKColor(0, 0, 0, 1));
            Assert.IsTrue(co.isValid(EnumValidationLevel.Incomplete));
            co.setAttribute("ActualColorName", "Schwarz");

            co = colPool.appendColorWithName("Yellow", null);
            co.setAttribute("ActualColorName", "Gelb");
            co.setCMYK(new JDFCMYKColor(0, 0, 1, 0));

            co = colPool.appendColorWithName("Cyan", null);
            co.setXMLComment("ActualColorName defaults to Name if not specified");
            co.setCMYK(new JDFCMYKColor(1, 0, 0, 0));

            co = colPool.appendColorWithName("Magenta", null);
            co = colPool.appendColorWithName("Spot1", null);
            co.setAttribute("ActualColorName", "Acme Aqua");
            co.setCMYK(new JDFCMYKColor(0.7, 0.2, 0.03, 0.1));

            co = colPool.appendColorWithName("BlackText", null);
            co.setAttribute("ActualColorName", "VersionsText");
            co.setCMYK(new JDFCMYKColor(0, 0, 0, 1));

            d.write2File(sm_dirTestDataTemp + "ActualColorName_Prepress.jdf", 2, false);

            JDFColorantAlias ca = colControl.appendColorantAlias();

            ca.setXMLComment("ColorantAlias that maps the additional representation (noir) to the predefined separation Black");
            ca.setReplacementColorantName("Black");
            Assert.IsTrue(ca.isValid(EnumValidationLevel.Incomplete));
            Assert.IsFalse(ca.isValid(EnumValidationLevel.Complete));
            VString vAlias = new VString("noir schwärz", null);

            ca.setSeparations(vAlias);
            Assert.IsTrue(ca.isValid(EnumValidationLevel.Complete));
            byte[] b        = Encoding.Default.GetBytes(vAlias.stringAt(0));
            string rawNames = StringUtil.setHexBinaryBytes(b, -1) + " ";

            b         = Encoding.Default.GetBytes(vAlias.stringAt(1));
            rawNames += StringUtil.setHexBinaryBytes(b, -1);
            ca.setAttribute("RawNames", rawNames);
            d.write2File(sm_dirTestDataTemp + "ActualColorName_with_CA.jdf", 2, false);
        }
Example #26
0
        public virtual void testSeparatedTiff()
        {
            ArrayList v1 = StringUtil.tokenize("Cyan Magenta Yello Black", " ", false);
            ArrayList v2 = new ArrayList();

            for (int i = 0; i < v1.Count; i++)
            {
                v2.Add("FileInfo://device/dir/" + v1[i] + ".tif");
            }
            JDFRunList rl2 = rl.addSepRun(v2, v1, 0, 0, false);

            Assert.IsTrue(rl2.isValid(EnumValidationLevel.Complete));
        }
Example #27
0
        ///
        ///	 <summary> * Gets the 16 bit representation of the 8 bit color name Use String
        ///	 * GetRawBytes() to extract the 8 bit representation
        ///	 *  </summary>
        ///	 * <returns> String Name of the color extracted from RawName, or if this is
        ///	 *         missing from Name, using the default transcoder </returns>
        ///
        public virtual string get8BitName()
        {
            string strName = getAttribute(AttributeName.RAWNAME, null, null);

            if (strName != null)
            {
                byte[] rawName   = Encoding.Default.GetBytes(strName);
                byte[] foundName = StringUtil.getHexBinaryBytes(rawName);

                return(Encoding.Default.GetString(foundName));
            }
            return(getActualColorName());
        }
Example #28
0
        public virtual void testInvalidNameSpace()
        {
            JDFDoc     doc = new JDFDoc("JDF");
            JDFElement e   = doc.getJDFRoot();
            string     s   = JDFConstants.JDFNAMESPACE;

            s = StringUtil.replaceString(s, "_1_1", "_1_3");
            JDFElement e2 = (JDFElement)e.appendElement("ResourcePool", s);

            Assert.IsTrue(e2.getInvalidAttributes(EnumValidationLevel.Incomplete, true, 9999).Contains("xmlns"));
            e2 = (JDFElement)e.appendElement("ResourceLinkPool", "www.cip4.org");
            Assert.IsTrue(e2.getInvalidAttributes(EnumValidationLevel.Incomplete, true, 9999).Contains("xmlns"));
        }
Example #29
0
        ///
        ///	 <summary> * get the email address of this, if this is an email address, else null any
        ///	 * "mailto" is stripped
        ///	 *
        ///	 * @return </summary>
        ///
        public virtual string getEMailAddress()
        {
            if (!EnumChannelType.Email.Equals(getChannelType()))
            {
                return(null);
            }
            string locator = getLocator();

            if (!StringUtil.matchesIgnoreCase(locator, JDFConstants.REGEXP_EMAIL))
            {
                return(null);
            }
            return(StringUtil.stripPrefix(locator, MAILTO, true));
        }
Example #30
0
        ///
        ///	 <summary> * setString - deserialize a string Reads the string, which represents JDFRectangleRangeList, and converts it into
        ///	 * real JDFRectangleRangeList
        ///	 *  </summary>
        ///	 * <param name="s"> string to read
        ///	 *  </param>
        ///	 * <exception cref="FormatException"> - if the String has not a valid format </exception>
        ///
        public virtual void setString(string s)
        {
            if (s.IndexOf(JDFConstants.TILDE) == 0 || s.LastIndexOf(JDFConstants.TILDE) == (s.Length - 1))
            {
                throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
            }
            string zappedWS = StringUtil.zappTokenWS(s, JDFConstants.TILDE); // converts
            // "0 0 1 1 ~ 0 0 4 4"
            // to
            // "0 0 1 1~0 0 4 4"
            VString vs = new VString(zappedWS, JDFConstants.BLANK);

            rangeList.Clear();
            for (int i = 0, size = vs.Count; i < size; i++)
            {
                if (size - i < JDFBaseDataTypes_Fields.MAX_RECTANGLE_DIMENSION) // the last Rectangle is
                // incomplete
                {
                    throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                }

                StringBuilder str = new StringBuilder(100);
                str.Append(vs[i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK);
                // the 4-th token 'tildeToken' can be with or without "~"
                string tildeToken = vs[++i];
                str.Append(tildeToken);
                if (tildeToken.IndexOf(JDFConstants.TILDE) != -1) // str -
                // JDFRectangleRange
                {
                    if (size - i < JDFBaseDataTypes_Fields.MAX_RECTANGLE_DIMENSION) // the last
                    // RectangleRange is
                    // incomplete
                    {
                        throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                    }

                    str.Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]);
                }
                try
                {
                    JDFRectangleRange r = new JDFRectangleRange(str.ToString());
                    rangeList.Add(r);
                }
                catch (FormatException)
                {
                    throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                }
            }
        }