All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infrastructurebuilder.data.model.DataSetInputLocation Maven / Gradle / Ivy

The newest version!
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello 1.11,
// any modifications will be overwritten.
// ==============================================================

package org.infrastructurebuilder.data.model;

/**
 * Class DataSetInputLocation.
 * 
 * @version $Revision$ $Date$
 */
public final class DataSetInputLocation
    implements java.io.Serializable, java.lang.Cloneable, org.infrastructurebuilder.data.model.DataSetInputLocationTracker
{

      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * The one-based line number. The value will be non-positive if
     * unknown.
     */
    private int lineNumber = -1;

    /**
     * The one-based column number. The value will be non-positive
     * if unknown.
     */
    private int columnNumber = -1;

    /**
     * Field source.
     */
    private DataSetInputSource source;

    /**
     * Field locations.
     */
    private java.util.Map locations;

    /**
     * Field location.
     */
    private DataSetInputLocation location;


      //----------------/
     //- Constructors -/
    //----------------/

    public DataSetInputLocation(int lineNumber, int columnNumber)
    {
        this.lineNumber = lineNumber;
        this.columnNumber = columnNumber;
    } //-- org.infrastructurebuilder.data.model.DataSetInputLocation(int, int)

    public DataSetInputLocation(int lineNumber, int columnNumber, DataSetInputSource source)
    {
        this.lineNumber = lineNumber;
        this.columnNumber = columnNumber;
        this.source = source;
    } //-- org.infrastructurebuilder.data.model.DataSetInputLocation(int, int, DataSetInputSource)


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Method clone.
     * 
     * @return DataSetInputLocation
     */
    public DataSetInputLocation clone()
    {
        try
        {
            DataSetInputLocation copy = (DataSetInputLocation) super.clone();

            if ( copy.locations != null )
            {
                copy.locations = new java.util.LinkedHashMap( copy.locations );
            }

            return copy;
        }
        catch ( java.lang.Exception ex )
        {
            throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
                + " does not support clone()" ).initCause( ex );
        }
    } //-- DataSetInputLocation clone()

    /**
     * Get the one-based column number. The value will be
     * non-positive if unknown.
     * 
     * @return int
     */
    public int getColumnNumber()
    {
        return this.columnNumber;
    } //-- int getColumnNumber()

    /**
     * Get the one-based line number. The value will be
     * non-positive if unknown.
     * 
     * @return int
     */
    public int getLineNumber()
    {
        return this.lineNumber;
    } //-- int getLineNumber()

    /**
     * 
     * 
     * @param key
     * @return DataSetInputLocation
     */
    public DataSetInputLocation getLocation( Object key )
    {
        if ( key instanceof String )
        {
            switch ( ( String ) key )
            {
                case "" :
                {
                    return this.location;
                }
                default :
                {
                    return getOtherLocation( key );
                }
                }
            }
            else
            {
                return getOtherLocation( key );
            }
    } //-- DataSetInputLocation getLocation( Object )

    /**
     * 
     * 
     * @return Map
     */
    public java.util.Map getLocations()
    {
        return locations;
    } //-- java.util.Map getLocations()

    /**
     * 
     * 
     * @param key
     * @param location
     */
    public void setLocation( Object key, DataSetInputLocation location )
    {
        if ( key instanceof String )
        {
            switch ( ( String ) key )
            {
                case "" :
                {
                    this.location = location;
                    return;
                }
                default :
                {
                    setOtherLocation( key, location );
                    return;
                }
                }
            }
            else
            {
                setOtherLocation( key, location );
            }
    } //-- void setLocation( Object, DataSetInputLocation )

    /**
     * 
     * 
     * @param key
     * @param location
     */
    public void setOtherLocation( Object key, DataSetInputLocation location )
    {
        if ( location != null )
        {
            if ( this.locations == null )
            {
                this.locations = new java.util.LinkedHashMap();
            }
            this.locations.put( key, location );
        }
    } //-- void setOtherLocation( Object, DataSetInputLocation )

    /**
     * 
     * 
     * @param key
     * @return DataSetInputLocation
     */
    private DataSetInputLocation getOtherLocation( Object key )
    {
        return ( locations != null ) ? locations.get( key ) : null;
    } //-- DataSetInputLocation getOtherLocation( Object )

    /**
     * Get the source field.
     * 
     * @return DataSetInputSource
     */
    public DataSetInputSource getSource()
    {
        return this.source;
    } //-- DataSetInputSource getSource()

    /**
     * Method merge.
     * 
     * @param target
     * @param sourceDominant
     * @param source
     * @return DataSetInputLocation
     */
    public static DataSetInputLocation merge( DataSetInputLocation target, DataSetInputLocation source, boolean sourceDominant )
    {
        if ( source == null )
        {
            return target;
        }
        else if ( target == null )
        {
            return source;
        }

        DataSetInputLocation result =
            new DataSetInputLocation( target.getLineNumber(), target.getColumnNumber(), target.getSource() );

        java.util.Map locations;
        java.util.Map sourceLocations = source.getLocations();
        java.util.Map targetLocations = target.getLocations();
        if ( sourceLocations == null )
        {
            locations = targetLocations;
        }
        else if ( targetLocations == null )
        {
            locations = sourceLocations;
        }
        else
        {
            locations = new java.util.LinkedHashMap();
            locations.putAll( sourceDominant ? targetLocations : sourceLocations );
            locations.putAll( sourceDominant ? sourceLocations : targetLocations );
        }
        result.setLocations( locations );

        return result;
    } //-- DataSetInputLocation merge( DataSetInputLocation, DataSetInputLocation, boolean )

    /**
     * Method merge.
     * 
     * @param target
     * @param indices
     * @param source
     * @return DataSetInputLocation
     */
    public static DataSetInputLocation merge( DataSetInputLocation target, DataSetInputLocation source, java.util.Collection indices )
    {
        if ( source == null )
        {
            return target;
        }
        else if ( target == null )
        {
            return source;
        }

        DataSetInputLocation result =
            new DataSetInputLocation( target.getLineNumber(), target.getColumnNumber(), target.getSource() );

        java.util.Map locations;
        java.util.Map sourceLocations = source.getLocations();
        java.util.Map targetLocations = target.getLocations();
        if ( sourceLocations == null )
        {
            locations = targetLocations;
        }
        else if ( targetLocations == null )
        {
            locations = sourceLocations;
        }
        else
        {
            locations = new java.util.LinkedHashMap();
            for ( java.util.Iterator it = indices.iterator(); it.hasNext(); )
            {
                DataSetInputLocation location;
                Integer index = it.next();
                if ( index.intValue() < 0 )
                {
                    location = sourceLocations.get( Integer.valueOf( ~index.intValue() ) );
                }
                else
                {
                    location = targetLocations.get( index );
                }
                locations.put( Integer.valueOf( locations.size() ), location );
            }
        }
        result.setLocations( locations );

        return result;
    } //-- DataSetInputLocation merge( DataSetInputLocation, DataSetInputLocation, java.util.Collection )

    /**
     * 
     * 
     * @param locations
     */
    public void setLocations( java.util.Map locations )
    {
        this.locations = locations;
    } //-- void setLocations( java.util.Map )


      //-----------------/
     //- Inner Classes -/
    //-----------------/

    /**
     * Class StringFormatter.
     * 
     * @version $Revision$ $Date$
     */
    public abstract static class StringFormatter
    {

          //-----------/
         //- Methods -/
        //-----------/

        /**
         * Method toString.
         * 
         * @param location
         * @return String
         */
        public abstract String toString( DataSetInputLocation location );

    }

    
            

    @Override
    public String toString()
    {
        return getLineNumber() + " : " + getColumnNumber() + ", " + getSource();
    }
            
          
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy