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.

ConfigurationStandard.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * This file is part of the debugger and core tools for the AspectJ(tm)
  4. * programming language; see http://aspectj.org
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License at
  9. * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is AspectJ.
  17. *
  18. * The Initial Developer of the Original Code is Xerox Corporation. Portions
  19. * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
  20. * All Rights Reserved.
  21. */
  22. package org.aspectj.tools.doclets.standard;
  23. import com.sun.javadoc.RootDoc;
  24. import com.sun.tools.doclets.MessageRetriever;
  25. import java.io.IOException;
  26. import java.net.URL;
  27. import java.util.Locale;
  28. import java.util.MissingResourceException;
  29. import java.util.PropertyResourceBundle;
  30. import java.util.ResourceBundle;
  31. /**
  32. * A customized configuration.
  33. *
  34. * @author Jeff Palm
  35. */
  36. public class ConfigurationStandard
  37. extends com.sun.tools.doclets.standard.ConfigurationStandard
  38. {
  39. /** It true we don't print crosscut information. */
  40. public boolean nocrosscuts = false;
  41. /** If true we don't print crosscut summary information. */
  42. public boolean nosummarycrosscuts = false;
  43. /** If true we log each pass in the doclet. */
  44. public boolean log = false;
  45. public ConfigurationStandard() {
  46. // standardmessage = new MessageRetriever
  47. // ("org.aspectj.tools.doclets.standard.resources.standard");
  48. String loc = "org.aspectj.tools.doclets.standard.resources.standard";
  49. final ClassLoader loader = getClass().getClassLoader();
  50. // XXX move persistant resource loader to util
  51. ResourceBundle bundle = null;
  52. for (int i = 0; ((null == bundle) && (i < 4)); i++) {
  53. try {
  54. switch (i) {
  55. case 0:
  56. bundle = ResourceBundle.getBundle(loc);
  57. standardmessage = new MessageRetriever(bundle);
  58. break;
  59. case 1:
  60. Locale locale = Locale.getDefault();
  61. bundle = ResourceBundle.getBundle(loc, locale, loader);
  62. standardmessage = new MessageRetriever(bundle);
  63. break;
  64. case 2:
  65. standardmessage = new MessageRetriever(loc);
  66. break;
  67. case 3:
  68. URL pURL = loader.getResource(loc + ".properties");
  69. bundle = new PropertyResourceBundle(pURL.openStream());
  70. standardmessage = new MessageRetriever(loc);
  71. break;
  72. }
  73. break; // from for loop
  74. } catch (MissingResourceException e) { } // error below
  75. catch (IOException ie) { } // error below
  76. }
  77. if (null == bundle) {
  78. throw new Error("unable to load resource: " + loc);
  79. }
  80. }
  81. //TODO: Document the new options in help
  82. public void setSpecificDocletOptions(RootDoc root) {
  83. String[][] options = root.options();
  84. for (int i = 0; i < options.length; ++i) {
  85. String opt = options[i][0].toLowerCase();
  86. if (opt.equals("-nocrosscuts")) {
  87. nocrosscuts = true;
  88. nosummarycrosscuts = true;
  89. } else if (opt.equals("-nosummarycrosscuts")) {
  90. nosummarycrosscuts = true;
  91. } else if (opt.equals("-log")) {
  92. log = true;
  93. }
  94. }
  95. super.setSpecificDocletOptions(root);
  96. }
  97. public int specificDocletOptionLength(String opt) {
  98. if (opt.equals("-nocrosscuts") ||
  99. opt.equals("-nosummarycrosscuts") ||
  100. opt.equals("-log")) {
  101. return 1;
  102. }
  103. return super.specificDocletOptionLength(opt);
  104. }
  105. }