Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Visibility.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.fop.traits;
  18. import java.io.ObjectStreamException;
  19. import org.apache.fop.fo.Constants;
  20. public final class Visibility extends TraitEnum {
  21. private static final long serialVersionUID = 1L;
  22. private static final String[] VISIBILITY_NAMES = new String[]
  23. {"visible", "hidden", "collapse"};
  24. private static final int[] VISIBILITY_VALUES = new int[]
  25. {Constants.EN_VISIBLE, Constants.EN_HIDDEN, Constants.EN_COLLAPSE};
  26. /** border-style: none */
  27. public static final Visibility VISIBLE = new Visibility(0);
  28. /** border-style: hidden */
  29. public static final Visibility HIDDEN = new Visibility(1);
  30. /** border-style: dotted */
  31. public static final Visibility COLLAPSE = new Visibility(2);
  32. private static final Visibility[] VISIBILITIES = new Visibility[] {
  33. VISIBLE, HIDDEN, COLLAPSE};
  34. private Visibility(int index) {
  35. super(VISIBILITY_NAMES[index], VISIBILITY_VALUES[index]);
  36. }
  37. /**
  38. * Returns the enumeration/singleton object based on its name.
  39. * @param name the name of the enumeration value
  40. * @return the enumeration object
  41. */
  42. public static Visibility valueOf(String name) {
  43. for (Visibility v : VISIBILITIES) {
  44. if (v.getName().equalsIgnoreCase(name)) {
  45. return v;
  46. }
  47. }
  48. throw new IllegalArgumentException("Illegal visibility value: " + name);
  49. }
  50. private Object readResolve() throws ObjectStreamException {
  51. return valueOf(getName());
  52. }
  53. public String toString() {
  54. return getName();
  55. }
  56. }