示例#1
0
        /**
         * Sets the text value of this element from its representative date parts.
         * This is called any time one of the integral components of the date is set,
         * overwriting any previous text value
         */
        private void calculateTextValue()
        {
            // Do not call setField( ElementDef, SIFSimplyType ) because it would cause
            // the integral components to have to be re-parsed
            if (fDate[0] == null)
            {
                // No year component
                RemoveField(CommonDTD.PARTIALDATETYPE);
            }
            else
            {
                String textValue = null;
                if (fDate[1] == null)
                {
                    // Year only
                    textValue = String.Format("{0:0000}", fDate[0].Value);
                }
                else if (fDate[2] == null)
                {
                    // Year-month only
                    textValue = String.Format("{0:0000}-{1:00}", fDate[0].Value, fDate[1].Value);
                }
                else
                {
                    textValue = String.Format("{0:0000}-{1:00}-{2:00}", fDate[0].Value, fDate[1].Value, fDate[2].Value);
                }

                SifString   value = new SifString(textValue);
                SimpleField field = value.CreateField(this, CommonDTD.PARTIALDATETYPE);
                SetField(field);
            }
        }
        /**
         * Sets the text value of this element from its representative date parts.
         * This is called any time one of the integral components of the date is set,
         * overwriting any previous text value
         */
        private void calculateTextValue()
        {
            // Do not call setField( ElementDef, SIFSimplyType ) because it would cause
            // the integral components to have to be re-parsed
            if( fDate[0] == null  )
            {
            // No year component
            RemoveField( CommonDTD.PARTIALDATETYPE );
            }
            else
            {
            String textValue = null;
            if( fDate[1] == null ){
                // Year only
                textValue = String.Format( "{0:0000}", fDate[0].Value );
            } else if ( fDate[2] == null ){
                // Year-month only
                textValue = String.Format( "{0:0000}-{1:00}", fDate[ 0 ].Value, fDate[ 1 ].Value );
            } else {
                textValue = String.Format( "{0:0000}-{1:00}-{2:00}", fDate[ 0 ].Value, fDate[ 1 ].Value, fDate[ 2 ].Value );
            }

            SifString value = new SifString( textValue );
            SimpleField field = value.CreateField( this, CommonDTD.PARTIALDATETYPE );
            SetField( field );
            }
        }