001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Copyright (c) 2010 The JOMC Project
005     *   Copyright (c) 2005 Christian Schulte <schulte2005@users.sourceforge.net>
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
021     *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
022     *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
023     *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
024     *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025     *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026     *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
027     *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
028     *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
029     *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
030     *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031     *
032     *   $Id: SequenceLimitException.java 2244 2010-06-29 07:58:09Z schulte2005 $
033     *
034     */
035    // </editor-fold>
036    // SECTION-END
037    package org.jomc.sequences;
038    
039    // SECTION-START[Documentation]
040    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
041    /**
042     * Gets thrown whenever the next value of a sequence is requested although its maximum value has already been reached.
043     * <p><b>Dependencies</b><ul>
044     * <li>"{@link #getLocale Locale}"<blockquote>
045     * Dependency on {@code 'java.util.Locale'} {@code (java.util.Locale)} at specification level 1.1 bound to an instance.</blockquote></li>
046     * </ul></p>
047     * <p><b>Messages</b><ul>
048     * <li>"{@link #getSequenceLimitMessage sequenceLimitMessage}"<table>
049     * <tr><td valign="top">English:</td><td valign="top"><pre>The maximum sequence value {0,number} has been reached. No more sequence values available.</pre></td></tr>
050     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Der Maximalwert {0,number} der Sequenz wurde erreicht. Keine weiteren Sequenz-Werte verf&uuml;gbar.</pre></td></tr>
051     * </table>
052     * </ul></p>
053     *
054     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
055     * @version $Id: SequenceLimitException.java 2244 2010-06-29 07:58:09Z schulte2005 $
056     */
057    // </editor-fold>
058    // SECTION-END
059    // SECTION-START[Annotations]
060    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
061    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
062    // </editor-fold>
063    // SECTION-END
064    public class SequenceLimitException extends SequencesException
065    {
066        // SECTION-START[SequenceLimitException]
067    
068        /** Serial version UID for backwards compatibility with 1.0.x classes. */
069        private static final long serialVersionUID = 4150038054934683080L;
070    
071        /**
072         * Current value of the sequence.
073         * @serial
074         */
075        private final long currentValue;
076    
077        /**
078         * Creates a new {@code SequenceLimitException} taking the current value of the sequence.
079         *
080         * @param currentValue The current value of the sequence reaching its limit.
081         */
082        public SequenceLimitException( final long currentValue )
083        {
084            super();
085            this.currentValue = currentValue;
086        }
087    
088        /**
089         * Gets the current value of the sequence reaching its limit.
090         *
091         * @return The current value of the sequence reaching its limit.
092         */
093        public long getCurrentValue()
094        {
095            return this.currentValue;
096        }
097    
098        /**
099         * Gets the message of the exception.
100         *
101         * @return The message of the exception.
102         */
103        @Override
104        public String getMessage()
105        {
106            return this.getSequenceLimitMessage( this.getLocale(), Long.valueOf( this.getCurrentValue() ) );
107        }
108    
109        // SECTION-END
110        // SECTION-START[Dependencies]
111        // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
112    
113        /**
114         * Gets the {@code Locale} dependency.
115         * <p>This method returns the {@code 'default'} object of the {@code 'java.util.Locale'} {@code (java.util.Locale)} specification at specification level 1.1.</p>
116         * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p>
117         * @return The {@code Locale} dependency.
118         * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
119         */
120        @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
121        private java.util.Locale getLocale()
122        {
123            final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
124            assert _d != null : "'Locale' dependency not found.";
125            return _d;
126        }
127        // </editor-fold>
128        // SECTION-END
129        // SECTION-START[Properties]
130        // SECTION-END
131        // SECTION-START[Messages]
132        // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
133    
134        /**
135         * Gets the text of the {@code sequenceLimitMessage} message.
136         * <p><b>Templates</b><br/><table>
137         * <tr><td valign="top">English:</td><td valign="top"><pre>The maximum sequence value {0,number} has been reached. No more sequence values available.</pre></td></tr>
138         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Der Maximalwert {0,number} der Sequenz wurde erreicht. Keine weiteren Sequenz-Werte verf&uuml;gbar.</pre></td></tr>
139         * </table></p>
140         * @param locale The locale of the message to return.
141         * @param sequenceLimit Format argument.
142         * @return The text of the {@code sequenceLimitMessage} message.
143         *
144         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
145         */
146        @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.0", comments = "See http://jomc.sourceforge.net/jomc/1.0/jomc-tools" )
147        private String getSequenceLimitMessage( final java.util.Locale locale, final java.lang.Number sequenceLimit )
148        {
149            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "sequenceLimitMessage", locale, sequenceLimit );
150            assert _m != null : "'sequenceLimitMessage' message not found.";
151            return _m;
152        }
153        // </editor-fold>
154        // SECTION-END
155    }