You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NullConfiguration.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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: Accessibility.java 1343632 2012-05-29 09:48:03Z vhennebert $ */
  18. package org.apache.fop.configuration;
  19. final class NullConfiguration implements Configuration {
  20. static final NullConfiguration INSTANCE = new NullConfiguration();
  21. private NullConfiguration() {
  22. }
  23. @Override
  24. public Configuration getChild(String key) {
  25. return INSTANCE;
  26. }
  27. @Override
  28. public Configuration getChild(String key, boolean required) {
  29. return INSTANCE;
  30. }
  31. @Override
  32. public Configuration[] getChildren(String key) {
  33. return new Configuration[0];
  34. }
  35. @Override
  36. public String[] getAttributeNames() {
  37. return new String[0];
  38. }
  39. @Override
  40. public String getAttribute(String key) throws ConfigurationException {
  41. return "";
  42. }
  43. @Override
  44. public String getAttribute(String key, String defaultValue) {
  45. return defaultValue;
  46. }
  47. @Override
  48. public boolean getAttributeAsBoolean(String key, boolean defaultValue) {
  49. return defaultValue;
  50. }
  51. @Override
  52. public float getAttributeAsFloat(String key) throws ConfigurationException {
  53. return 0;
  54. }
  55. @Override
  56. public float getAttributeAsFloat(String key, float defaultValue) {
  57. return defaultValue;
  58. }
  59. @Override
  60. public int getAttributeAsInteger(String key, int defaultValue) {
  61. return defaultValue;
  62. }
  63. @Override
  64. public String getValue() throws ConfigurationException {
  65. // return null;
  66. throw new ConfigurationException("missing value");
  67. }
  68. @Override
  69. public String getValue(String defaultValue) {
  70. return defaultValue;
  71. }
  72. @Override
  73. public boolean getValueAsBoolean() throws ConfigurationException {
  74. return false;
  75. }
  76. @Override
  77. public boolean getValueAsBoolean(boolean defaultValue) {
  78. return defaultValue;
  79. }
  80. @Override
  81. public int getValueAsInteger() throws ConfigurationException {
  82. return 0;
  83. }
  84. @Override
  85. public int getValueAsInteger(int defaultValue) {
  86. return defaultValue;
  87. }
  88. @Override
  89. public float getValueAsFloat() throws ConfigurationException {
  90. return 0;
  91. }
  92. @Override
  93. public float getValueAsFloat(float defaultValue) {
  94. return defaultValue;
  95. }
  96. @Override
  97. public String getLocation() {
  98. return "<no-location>";
  99. }
  100. }