Source for gnu.javax.print.ipp.attribute.supported.FinishingsSupported

   1: /* FinishingsSupported.java --
   2:    Copyright (C) 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package gnu.javax.print.ipp.attribute.supported;
  40: 
  41: import gnu.javax.print.ipp.IppUtilities;
  42: 
  43: import java.util.Iterator;
  44: import java.util.Set;
  45: 
  46: import javax.print.attribute.Attribute;
  47: import javax.print.attribute.EnumSyntax;
  48: import javax.print.attribute.SupportedValuesAttribute;
  49: import javax.print.attribute.standard.Finishings;
  50: 
  51: 
  52: /**
  53:  * The <code>FinishingsSupported</code> attribute provides the supported
  54:  * values for finishings of a job.
  55:  *
  56:  * @author Wolfgang Baer (WBaer@gmx.de)
  57:  */
  58: public final class FinishingsSupported extends EnumSyntax
  59:   implements SupportedValuesAttribute
  60: {
  61: 
  62:   /** No finishing. */
  63:   public static final FinishingsSupported NONE = new FinishingsSupported(3);
  64: 
  65:   /** Staple the document(s) */
  66:   public static final FinishingsSupported STAPLE = new FinishingsSupported(4);
  67: 
  68:   /** Cover a document */
  69:   public static final FinishingsSupported COVER = new FinishingsSupported(6);
  70: 
  71:   /**
  72:    * This value indicates that a binding is to be applied to the document.
  73:    * The type and placement of the binding is site-defined.
  74:    */
  75:   public static final FinishingsSupported BIND = new FinishingsSupported(7);
  76: 
  77:   /**
  78:    * Bind the document(s) with one or more staples (wire stitches)
  79:    * along the middle fold.
  80:    */
  81:   public static final FinishingsSupported SADDLE_STITCH =
  82:     new FinishingsSupported(8);
  83: 
  84:   /**
  85:    * Bind the document(s) with one or more staples (wire stitches)
  86:    * along one edge.
  87:    */
  88:   public static final FinishingsSupported EDGE_STITCH =
  89:     new FinishingsSupported(9);
  90: 
  91:   /**
  92:    * Bind the document(s) with one or more staples in the top left
  93:    * corner.
  94:    */
  95:   public static final FinishingsSupported STAPLE_TOP_LEFT =
  96:     new FinishingsSupported(20);
  97: 
  98:   /**
  99:    * Bind the document(s) with one or more staples in the bottom
 100:    * left corner.
 101:    */
 102:   public static final FinishingsSupported STAPLE_BOTTOM_LEFT =
 103:     new FinishingsSupported(21);
 104: 
 105:   /**
 106:    * Bind the document(s) with one or more staples in the top right corner.
 107:    */
 108:   public static final FinishingsSupported STAPLE_TOP_RIGHT =
 109:     new FinishingsSupported(22);
 110: 
 111:   /**
 112:    * Bind the document(s) with one or more staples in the bottom right corner.
 113:    */
 114:   public static final FinishingsSupported STAPLE_BOTTOM_RIGHT =
 115:     new FinishingsSupported(23);
 116: 
 117:   /**
 118:    * Bind the document(s) with one or more  staples (wire stitches)
 119:    * along the left edge.
 120:    */
 121:   public static final FinishingsSupported EDGE_STITCH_LEFT =
 122:     new FinishingsSupported(24);
 123: 
 124:   /**
 125:    * Bind the document(s) with one or more staples (wire stitches) along
 126:    * the top edge.
 127:    */
 128:   public static final FinishingsSupported EDGE_STITCH_TOP =
 129:     new FinishingsSupported(25);
 130: 
 131:   /**
 132:    * Bind the document(s) with one or more staples (wire stitches) along
 133:    * the right edge.
 134:    */
 135:   public static final FinishingsSupported EDGE_STITCH_RIGHT =
 136:     new FinishingsSupported(26);
 137: 
 138:   /**
 139:    * Bind the document(s) with one or more staples (wire stitches) along
 140:    * the bottom edge.
 141:    */
 142:   public static final FinishingsSupported EDGE_STITCH_BOTTOM =
 143:     new FinishingsSupported(27);
 144: 
 145:   /**
 146:    * Bind the document(s) with two staples (wire stitches) along the
 147:    * left edge assuming a portrait document.
 148:    */
 149:   public static final FinishingsSupported STAPLE_DUAL_LEFT =
 150:     new FinishingsSupported(28);
 151: 
 152:   /**
 153:    * Bind the document(s) with two staples (wire stitches) along the
 154:    * top edge assuming a portrait document.
 155:    */
 156:   public static final FinishingsSupported STAPLE_DUAL_TOP =
 157:     new FinishingsSupported(29);
 158: 
 159:   /**
 160:    * Bind the document(s) with two staples (wire stitches) along the
 161:    * right edge assuming a portrait document.
 162:    */
 163:   public static final FinishingsSupported STAPLE_DUAL_RIGHT =
 164:     new FinishingsSupported(30);
 165: 
 166:   /**
 167:    * Bind the document(s) with two staples (wire stitches) along the
 168:    * bottom edge assuming a portrait document.
 169:    */
 170:   public static final FinishingsSupported STAPLE_DUAL_BOTTOM =
 171:     new FinishingsSupported(31);
 172: 
 173:   private static final String[] stringTable = { "none", "staple", null,
 174:                                                 "cover", "bind", "saddle-stitch",
 175:                                                 "edge-stitch", null, null, null,
 176:                                                 null, null, null, null, null,
 177:                                                 null, null, "staple-top-left",
 178:                                                 "staple-bottom-left",
 179:                                                 "staple-top-right",
 180:                                                 "staple-bottom-right",
 181:                                                 "edge-stitch-left",
 182:                                                 "edge-stitch-top",
 183:                                                 "edge-stitch-right",
 184:                                                 "edge-stitch-bottom",
 185:                                                 "staple-dual-left",
 186:                                                 "staple-dual-top",
 187:                                                 "staple-dual-right",
 188:                                                 "staple-dual-bottom" };
 189: 
 190:   private static final FinishingsSupported[] enumValueTable = { NONE, STAPLE,
 191:                                                        null, COVER, BIND,
 192:                                                        SADDLE_STITCH,
 193:                                                        EDGE_STITCH, null,
 194:                                                        null, null, null,
 195:                                                        null, null, null,
 196:                                                        null, null, null,
 197:                                                        STAPLE_TOP_LEFT,
 198:                                                        STAPLE_BOTTOM_LEFT,
 199:                                                        STAPLE_TOP_RIGHT,
 200:                                                        STAPLE_BOTTOM_RIGHT,
 201:                                                        EDGE_STITCH_LEFT,
 202:                                                        EDGE_STITCH_TOP,
 203:                                                        EDGE_STITCH_RIGHT,
 204:                                                        EDGE_STITCH_BOTTOM,
 205:                                                        STAPLE_DUAL_LEFT,
 206:                                                        STAPLE_DUAL_TOP,
 207:                                                        STAPLE_DUAL_RIGHT,
 208:                                                        STAPLE_DUAL_BOTTOM };
 209: 
 210:   /**
 211:    * Constructs a <code>FinishingsSupported</code> object.
 212:    *
 213:    * @param value the value
 214:    */
 215:   protected FinishingsSupported(int value)
 216:   {
 217:     super(value);
 218:   }
 219: 
 220:   /**
 221:    * Returns category of this class.
 222:    *
 223:    * @return the class <code>FinishingsSupported</code> itself
 224:    */
 225:   public Class<? extends Attribute> getCategory()
 226:   {
 227:     return FinishingsSupported.class;
 228:   }
 229: 
 230:   /**
 231:    * Returns the name of this attribute.
 232:    *
 233:    * @return The name "finishings-supported".
 234:    */
 235:   public String getName()
 236:   {
 237:     return "finishings-supported";
 238:   }
 239: 
 240:   /**
 241:    * Returns a table with the enumeration values represented as strings
 242:    * for this object.
 243:    *
 244:    * @return The enumeration values as strings.
 245:    */
 246:   protected String[] getStringTable()
 247:   {
 248:     return stringTable;
 249:   }
 250: 
 251:   /**
 252:    * Returns a table with the enumeration values for this object.
 253:    *
 254:    * @return The enumeration values.
 255:    */
 256:   protected EnumSyntax[] getEnumValueTable()
 257:   {
 258:     return enumValueTable;
 259:   }
 260: 
 261:   /**
 262:    * Returns the lowest used value by the enumerations of this class.
 263:    * .
 264:    * @return The lowest value used.
 265:    */
 266:   protected int getOffset()
 267:   {
 268:     return 3;
 269:   }
 270: 
 271:   /**
 272:    * Returns the equally enum of the standard attribute class
 273:    * of this SupportedValuesAttribute enum.
 274:    *
 275:    * @return The enum of the standard attribute class.
 276:    */
 277:   public Finishings getAssociatedAttribute()
 278:   {
 279:     return (Finishings) IppUtilities.getEnumAttribute(
 280:            "finishings", new Integer(getValue()));
 281:   }
 282: 
 283:   /**
 284:    * Constructs an array from a set of -supported attributes.
 285:    * @param set set to process
 286:    * @return The constructed array.
 287:    *
 288:    * @see #getAssociatedAttribute()
 289:    */
 290:   public static Finishings[]
 291:     getAssociatedAttributeArray(Set<Attribute> set)
 292:   {
 293:     Finishings[] result = new Finishings[set.size()];
 294:     int j = 0;
 295:     for (Attribute tmp : set)
 296:       {
 297:         result[j] = ((FinishingsSupported) tmp).getAssociatedAttribute();
 298:         j++;
 299:       }
 300:     return result;
 301:   }
 302: }