예제 #1
0
        /**
         *  Clears the table
         */

        public void Clear()
        {
            fTable.Clear();
            fReverseTable.Clear();
            fDefaultAppEntry        = null;
            fDefaultSifEntry        = null;
            fRenderAppDefaultIfNull = false;
            fRenderSifDefaultIfNull = false;
        }
예제 #2
0
        /// <summary>  Performs a reverse translation.
        ///
        /// </summary>
        /// <param name="sifValue">An SIF-defined value
        /// </param>
        /// <returns> The corresponding application-defined value
        /// </returns>
        public virtual string TranslateReverse(string sifValue)
        {
            ValueSetEntry e = GetReverseEntry(sifValue);

            if (e != null)
            {
                return(e.Name);
            }
            else
            {
                return(EvaluateDefault(
                           fDefaultAppEntry == null ? null : fDefaultAppEntry.Name,
                           fRenderAppDefaultIfNull, sifValue));
            }
        }
예제 #3
0
        /// <summary>  Translates a value.
        ///
        /// This method differs from <code>get</code> in that it returns <i>appValue</i>
        /// if no mapping is defined in the ValueSet. The <code>get</code> method
        /// returns null if no mapping is defined.
        ///
        ///
        /// </summary>
        /// <param name="appValue">An application-defined value
        /// </param>
        /// <returns> The corresponding SIF-defined value
        /// </returns>
        public virtual string Translate(string appValue)
        {
            ValueSetEntry e = GetEntry(appValue);

            if (e != null)
            {
                return(e.Value);
            }
            else
            {
                return(EvaluateDefault(
                           fDefaultSifEntry == null ? null : fDefaultSifEntry.Value,
                           fRenderSifDefaultIfNull, appValue));
            }
        }
예제 #4
0
        /**
         * Sets the default SIF value that will be returned if no match
         * is found during a valueset translation
         * @param sifValue The value to return if there is no match. Pass in <code>Null</code> if the
         * previously-set default is to be removed
         * @param renderIfNull True if the default value should be returned even if the app value
         * being translated is null. If false, NULL will be returned.
         * @throws ADKMappingException Thrown if the value has not yet been defined in this valueset
         * by calling <code>define</code>
         *
         * @see #define(String, String, String)
         * @see #define(String, String, String, Node)
         */

        public void SetSifDefault(String sifValue, bool renderIfNull)

        {
            fRenderSifDefaultIfNull = renderIfNull;
            if (fDefaultSifEntry != null)
            {
                ValueSetEntry oldEntry = fDefaultSifEntry;
                fDefaultSifEntry = null;
                ToXml(oldEntry, oldEntry.Node);
            }
            if (sifValue != null)
            {
                ValueSetEntry entry = GetReverseEntry(sifValue);
                if (entry == null)
                {
                    throw new AdkMappingException("Value: '" + sifValue + "' is not defined.", null);
                }
                fDefaultSifEntry = entry;
                ToXml(fDefaultSifEntry, fDefaultSifEntry.Node);
            }
        }
예제 #5
0
        /// <summary>  Sets a value</summary>
        public virtual void Define(string appValue,
                                   string sifValue,
                                   string title,
                                   XmlElement node)
        {
            if (appValue != null)
            {
                ValueSetEntry entry = new ValueSetEntry(appValue, sifValue, title);
                entry.DisplayOrder = fTable.Count;
                entry.Node         = node;

                if (node != null)
                {
                    entry.ToXml(node);
                }


                fTable[appValue]        = entry;
                fReverseTable[sifValue] = entry;
            }
        }
예제 #6
0
        private void ToXml(ValueSetEntry entry, XmlElement element)
        {
            // If the element passed in is null, this ValueSet doesn't currently have an
            // XML Element that it is associated with. This is OK. Exit Gracefully.
            if (element == null)
            {
                return;
            }

            entry.ToXml(element);

            // Since this class controls the notion of defaults, write the
            // attributes controlling defaults here
            bool isDefaultAppValue = fDefaultAppEntry == entry;
            bool isDefaultSifValue = fDefaultSifEntry == entry;

            if (isDefaultAppValue)
            {
                if (isDefaultSifValue)
                {
                    element.SetAttribute("default", "both");
                    element.SetAttribute("ifnull", GetIfNull(fRenderSifDefaultIfNull));
                }
                else
                {
                    element.SetAttribute("default", "inbound");
                    element.SetAttribute("ifnull", GetIfNull(fRenderAppDefaultIfNull));
                }
            }
            else if (isDefaultSifValue)
            {
                element.SetAttribute("default", "outbound");
                element.SetAttribute("ifnull", GetIfNull(fRenderSifDefaultIfNull));
            }
            else
            {
                element.RemoveAttribute("default");
                element.RemoveAttribute("ifnull");
            }
        }
예제 #7
0
        /**
         *  Removes a value
         */

        public void Remove(String appValue)
        {
            if (appValue != null)
            {
                ValueSetEntry entry = (ValueSetEntry)fTable[appValue];
                if (entry != null)
                {
                    fTable.Remove(appValue);
                    fReverseTable.Remove(entry.Value);
                    fNode.RemoveChild(entry.Node);

                    if (fDefaultAppEntry == entry)
                    {
                        fDefaultAppEntry = null;
                    }
                    if (fDefaultSifEntry == entry)
                    {
                        fDefaultSifEntry = null;
                    }
                }
            }
        }
예제 #8
0
        /**
         * Sets the default application value that will be returned if no match
         * is found during a valueset translation
         * @param appValue The value to return if there is no match. Pass in <code>Null</code> if the
         * previously-set default is to be removed
         * @param renderIfNull True if the default value should be returned even if the SIF Value being
         * translated is NULL. If false, NULL will be returned.
         * @throws ADKMappingException Thrown if the value has not yet been defined in this valueset
         * by calling <code>define</code>
         */

        public void SetAppDefault(String appValue, bool renderIfNull)

        {
            fRenderAppDefaultIfNull = renderIfNull;
            if (fDefaultAppEntry != null)
            {
                ValueSetEntry oldEntry = fDefaultAppEntry;
                fDefaultAppEntry = null;
                ToXml(oldEntry, oldEntry.Node);
            }

            if (appValue != null)
            {
                ValueSetEntry entry = GetEntry(appValue);
                if (entry == null)
                {
                    throw new AdkMappingException("Value: '" + appValue + "' is not defined.", null);
                }
                fDefaultAppEntry = entry;
                ToXml(fDefaultAppEntry, fDefaultAppEntry.Node);
            }
        }
예제 #9
0
 /**
  *  Clears the table
  */
 public void Clear()
 {
     fTable.Clear();
     fReverseTable.Clear();
     fDefaultAppEntry = null;
     fDefaultSifEntry = null;
     fRenderAppDefaultIfNull = false;
     fRenderSifDefaultIfNull = false;
 }
예제 #10
0
 public ValueSetEntry[] GetEntries()
 {
     ValueSetEntry[] entries = new ValueSetEntry[fTable.Count];
     fTable.Values.CopyTo( entries, 0 );
     return entries;
 }
예제 #11
0
        /**
         *  Removes a value
         */
        public void Remove( String appValue )
        {
            if ( appValue != null )
            {
                ValueSetEntry entry = (ValueSetEntry) fTable[appValue];
                if ( entry != null )
                {
                    fTable.Remove( appValue );
                    fReverseTable.Remove( entry.Value );
                    fNode.RemoveChild( entry.Node );

                    if ( fDefaultAppEntry == entry )
                    {
                        fDefaultAppEntry = null;
                    }
                    if ( fDefaultSifEntry == entry )
                    {
                        fDefaultSifEntry = null;
                    }
                }
            }
        }
예제 #12
0
        /**
         * Looks up a ValueSetEntry by a SIF value
         * @param sifValue
         * @return The ValueSetEntry that matches, if found, or null
         */

        private ValueSetEntry GetReverseEntry(String sifValue)
        {
            ValueSetEntry e = sifValue != null ? (ValueSetEntry)fReverseTable[sifValue] : null;

            return(e);
        }
예제 #13
0
        /**
         * Gets a ValueSet entry for the specified application value
         * @param appValue
         * @return The ValueSetEntry that matches, if found, or null
         */

        private ValueSetEntry GetEntry(String appValue)
        {
            ValueSetEntry e = appValue != null ? (ValueSetEntry)fTable[appValue] : null;

            return(e);
        }
예제 #14
0
 public ValueSetEntry[] GetEntries()
 {
     ValueSetEntry[] entries = new ValueSetEntry[fTable.Count];
     fTable.Values.CopyTo(entries, 0);
     return(entries);
 }
예제 #15
0
        /**
         * Sets the default application value that will be returned if no match
         * is found during a valueset translation
         * @param appValue The value to return if there is no match. Pass in <code>Null</code> if the
         * previously-set default is to be removed
         * @param renderIfNull True if the default value should be returned even if the SIF Value being
         * translated is NULL. If false, NULL will be returned.
         * @throws ADKMappingException Thrown if the value has not yet been defined in this valueset
         	 * by calling <code>define</code>
         */
        public void SetAppDefault( String appValue, bool renderIfNull )
        {
            fRenderAppDefaultIfNull = renderIfNull;
            if ( fDefaultAppEntry != null )
            {
                ValueSetEntry oldEntry = fDefaultAppEntry;
                fDefaultAppEntry = null;
                ToXml( oldEntry, oldEntry.Node );
            }

            if ( appValue != null )
            {
                ValueSetEntry entry = GetEntry( appValue );
                if ( entry == null )
                {
                    throw new AdkMappingException( "Value: '" + appValue + "' is not defined.", null );
                }
                fDefaultAppEntry = entry;
                ToXml( fDefaultAppEntry, fDefaultAppEntry.Node );
            }
        }
예제 #16
0
        /// <summary>  Sets a value</summary>
        public virtual void Define( string appValue,
                                    string sifValue,
                                    string title,
                                    XmlElement node )
        {
            if ( appValue != null )
            {
                ValueSetEntry entry = new ValueSetEntry( appValue, sifValue, title );
                entry.DisplayOrder = fTable.Count;
                entry.Node = node;

                if ( node != null )
                {
                    entry.ToXml( node );
                }

                fTable[appValue] = entry;
                fReverseTable[sifValue] = entry;
            }
        }
예제 #17
0
        /// <summary>  Gets a value</summary>
        public virtual string Lookup(string appValue)
        {
            ValueSetEntry e = appValue == null ? null : (ValueSetEntry)fTable[appValue];

            return(e == null ? null : e.Value);
        }
예제 #18
0
 /**
  * Sets the default SIF value that will be returned if no match
  * is found during a valueset translation
  * @param sifValue The value to return if there is no match. Pass in <code>Null</code> if the
  * previously-set default is to be removed
  * @param renderIfNull True if the default value should be returned even if the app value
  * being translated is null. If false, NULL will be returned.
  * @throws ADKMappingException Thrown if the value has not yet been defined in this valueset
  * by calling <code>define</code>
  *
  * @see #define(String, String, String)
  * @see #define(String, String, String, Node)
  */
 public void SetSifDefault( String sifValue, bool renderIfNull )
 {
     fRenderSifDefaultIfNull = renderIfNull;
     if ( fDefaultSifEntry != null )
     {
         ValueSetEntry oldEntry = fDefaultSifEntry;
         fDefaultSifEntry = null;
         ToXml( oldEntry, oldEntry.Node );
     }
     if ( sifValue != null )
     {
         ValueSetEntry entry = GetReverseEntry( sifValue );
         if ( entry == null )
         {
             throw new AdkMappingException( "Value: '" + sifValue + "' is not defined.", null );
         }
         fDefaultSifEntry = entry;
         ToXml( fDefaultSifEntry, fDefaultSifEntry.Node );
     }
 }
예제 #19
0
        private void ToXml( ValueSetEntry entry, XmlElement element )
        {
            // If the element passed in is null, this ValueSet doesn't currently have an
            // XML Element that it is associated with. This is OK. Exit Gracefully.
            if ( element == null )
            {
                return;
            }

            entry.ToXml( element );

            // Since this class controls the notion of defaults, write the
            // attributes controlling defaults here
            bool isDefaultAppValue = fDefaultAppEntry == entry;
            bool isDefaultSifValue = fDefaultSifEntry == entry;
            if ( isDefaultAppValue )
            {
                if ( isDefaultSifValue )
                {
                    element.SetAttribute( "default", "both" );
                    element.SetAttribute( "ifnull", GetIfNull( fRenderSifDefaultIfNull ) );
                }
                else
                {
                    element.SetAttribute( "default", "inbound" );
                    element.SetAttribute( "ifnull", GetIfNull( fRenderAppDefaultIfNull ) );
                }
            }
            else if ( isDefaultSifValue )
            {
                element.SetAttribute( "default", "outbound" );
                element.SetAttribute( "ifnull", GetIfNull( fRenderSifDefaultIfNull ) );
            }
            else
            {
                element.RemoveAttribute( "default" );
                element.RemoveAttribute( "ifnull" );
            }
        }