Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AFPResourceInfo.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. /* $Id: $ */
  18. package org.apache.fop.afp;
  19. /**
  20. * The level at which a resource is to reside in the AFP output
  21. */
  22. public class AFPResourceInfo {
  23. private static final AFPResourceLevel DEFAULT_LEVEL
  24. = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
  25. /** the uri of this resource */
  26. private String uri = null;
  27. /** the reference name of this resource */
  28. private String name = null;
  29. /** the resource level of this resource */
  30. private AFPResourceLevel level = DEFAULT_LEVEL;
  31. /** true when the resource level was changed */
  32. private boolean levelChanged = false;
  33. /**
  34. * Sets the data object uri
  35. *
  36. * @param uri the data object uri
  37. */
  38. public void setUri(String uri) {
  39. this.uri = uri;
  40. }
  41. /**
  42. * Returns the uri of this data object
  43. *
  44. * @return the uri of this data object
  45. */
  46. public String getUri() {
  47. return uri;
  48. }
  49. /**
  50. * Sets the resource reference name
  51. *
  52. * @param resourceName the resource reference name
  53. */
  54. public void setName(String resourceName) {
  55. this.name = resourceName;
  56. }
  57. /**
  58. * Returns the resource reference name
  59. *
  60. * @return the resource reference name
  61. */
  62. public String getName() {
  63. return this.name;
  64. }
  65. /**
  66. * Returns the resource level
  67. *
  68. * @return the resource level
  69. */
  70. public AFPResourceLevel getLevel() {
  71. if (level == null) {
  72. return DEFAULT_LEVEL;
  73. }
  74. return this.level;
  75. }
  76. /**
  77. * Sets the resource level
  78. *
  79. * @param resourceLevel the resource level
  80. */
  81. public void setLevel(AFPResourceLevel resourceLevel) {
  82. this.level = resourceLevel;
  83. levelChanged = true;
  84. }
  85. /**
  86. * Returns true when the resource level was set
  87. *
  88. * @return true when the resource level was set
  89. */
  90. public boolean levelChanged() {
  91. return levelChanged;
  92. }
  93. /** {@inheritDoc} */
  94. public String toString() {
  95. return "AFPResourceInfo{uri=" + uri
  96. + (name != null ? ", name=" + name : "")
  97. + (level != null ? ", level=" + level : "")
  98. + "}";
  99. }
  100. /** {@inheritDoc} */
  101. public boolean equals(Object obj) {
  102. if (this == obj) {
  103. return true;
  104. }
  105. if ((obj == null) || !(obj instanceof AFPResourceInfo)) {
  106. return false;
  107. }
  108. AFPResourceInfo ri = (AFPResourceInfo)obj;
  109. return (uri == ri.uri || uri != null && uri.equals(ri.uri))
  110. && (name == ri.name || name != null && name.equals(ri.name))
  111. && (level == ri.level || level != null && level.equals(ri.level));
  112. }
  113. /** {@inheritDoc} */
  114. public int hashCode() {
  115. int hash = 7;
  116. hash = 31 * hash + (null == uri ? 0 : uri.hashCode());
  117. hash = 31 * hash + (null == name ? 0 : name.hashCode());
  118. hash = 31 * hash + (null == level ? 0 : level.hashCode());
  119. return hash;
  120. }
  121. }