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.

Property.java 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /*
  2. * $Id: Property.java,v 1.22 2003/03/05 21:48:02 jeremias Exp $
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.fo;
  52. import org.apache.fop.datatypes.ColorType;
  53. import org.apache.fop.datatypes.CondLength;
  54. import org.apache.fop.datatypes.CompoundDatatype;
  55. import org.apache.fop.datatypes.Keep;
  56. import org.apache.fop.datatypes.Length;
  57. import org.apache.fop.datatypes.LengthPair;
  58. import org.apache.fop.datatypes.LengthRange;
  59. import org.apache.fop.datatypes.PercentBase;
  60. import org.apache.fop.datatypes.LengthBase;
  61. import org.apache.fop.datatypes.Space;
  62. import org.apache.fop.fo.expr.Numeric;
  63. import org.apache.fop.fo.expr.PropertyParser;
  64. import org.apache.fop.fo.expr.PropertyInfo;
  65. import org.apache.fop.apps.FOPException;
  66. import java.util.Vector;
  67. import java.util.HashMap;
  68. import java.util.Map;
  69. /**
  70. * Base class for all property objects
  71. * @author unascribed
  72. */
  73. public class Property {
  74. /**
  75. * Base class for all property makers
  76. * @author unascribed
  77. */
  78. public static class Maker implements Cloneable {
  79. protected int propId;
  80. private boolean inherited = true;
  81. private Map enums = null;
  82. private Map keywords = null;
  83. protected String defaultValue = null;
  84. protected boolean contextDep = false;
  85. protected boolean setByShorthand = false;
  86. private int percentBase = -1;
  87. private Property.Maker[] shorthands = null;
  88. private ShorthandParser datatypeParser;
  89. protected Property defaultProperty;
  90. protected CorrespondingPropertyMaker corresponding;
  91. /**
  92. * @return the name of the property for this Maker
  93. */
  94. protected int getPropId() {
  95. return propId;
  96. }
  97. /**
  98. * Construct an instance of a Property.Maker for the given property.
  99. * @param propId The Constant ID of the property to be made.
  100. */
  101. public Maker(int propId) {
  102. this.propId = propId;
  103. }
  104. /**
  105. * Copy all the values from the generic maker to this maker.
  106. * @param generic a generic property maker.
  107. */
  108. public void useGeneric(Property.Maker generic) {
  109. contextDep = generic.contextDep;
  110. inherited = generic.inherited;
  111. defaultValue = generic.defaultValue;
  112. percentBase = generic.percentBase;
  113. if (generic.shorthands != null) {
  114. shorthands = new Property.Maker[generic.shorthands.length];
  115. System.arraycopy(shorthands, 0, generic.shorthands, 0, shorthands.length);
  116. }
  117. if (generic.enums != null) {
  118. enums = new HashMap(generic.enums);
  119. }
  120. if (generic.keywords != null) {
  121. keywords = new HashMap(generic.keywords);
  122. }
  123. }
  124. /**
  125. * Set the inherited flag.
  126. * @param inherited
  127. */
  128. public void setInherited(boolean inherited) {
  129. this.inherited = inherited;
  130. }
  131. /**
  132. * Add a keyword-equiv to the maker.
  133. * @param keyword
  134. * @param value
  135. */
  136. public void addKeyword(String keyword, String value) {
  137. if (keywords == null) {
  138. keywords = new HashMap();
  139. }
  140. keywords.put(keyword, value);
  141. }
  142. /**
  143. * Add a enum constant.
  144. * @param constant
  145. * @param value
  146. */
  147. public void addEnum(String constant, Property value) {
  148. if (enums == null) {
  149. enums = new HashMap();
  150. }
  151. enums.put(constant, value);
  152. }
  153. /**
  154. * Add a subproperty to this maker.
  155. * @param subproperty
  156. */
  157. public void addSubpropMaker(Property.Maker subproperty) {
  158. throw new RuntimeException("Unable to add subproperties " + getClass());
  159. }
  160. /**
  161. * Return a subproperty maker for the subpropId.
  162. * @param subpropId The subpropId of the maker.
  163. * @return The subproperty maker.
  164. */
  165. public Property.Maker getSubpropMaker(int subpropId) {
  166. throw new RuntimeException("Unable to add subproperties");
  167. }
  168. /**
  169. * Add a shorthand to this maker. Only an Integer is added to the
  170. * shorthands list. Later the Integers are replaced with references
  171. * to the actual shorthand property makers.
  172. * @param shorthand a property maker thar is that is checked for
  173. * shorthand values.
  174. */
  175. public void addShorthand(Property.Maker shorthand) {
  176. if (shorthands == null) {
  177. shorthands = new Property.Maker[3];
  178. }
  179. for (int i = 0; i < shorthands.length; i++) {
  180. if (shorthands[i] == null) {
  181. shorthands[i] = shorthand;
  182. break;
  183. }
  184. }
  185. }
  186. /**
  187. * Set the shorthand datatype parser.
  188. * @param subproperty
  189. */
  190. public void setDatatypeParser(ShorthandParser parser) {
  191. datatypeParser = parser;
  192. }
  193. /**
  194. * Set the default value for this maker.
  195. * @param defaultValue the default value.
  196. */
  197. public void setDefault(String defaultValue) {
  198. this.defaultValue = defaultValue;
  199. }
  200. /**
  201. * Set the default value for this maker.
  202. * @param defaultValue
  203. * @param contextDep true when the value context dependent and
  204. * must not be cached.
  205. */
  206. public void setDefault(String defaultValue, boolean contextDep) {
  207. this.defaultValue = defaultValue;
  208. this.contextDep = contextDep;
  209. }
  210. /**
  211. * Set the percent base identifier for this maker.
  212. * @param percentBase
  213. */
  214. public void setPercentBase(int percentBase) {
  215. this.percentBase = percentBase;
  216. }
  217. /**
  218. * Set the byShorthand flag which only is applicable for subproperty
  219. * makers. It should be true for the subproperties which must be
  220. * assigned a value when the base property is assigned a attribute
  221. * value directly.
  222. * @param defaultValue
  223. */
  224. public void setByShorthand(boolean setByShorthand) {
  225. this.setByShorthand = setByShorthand;
  226. }
  227. /**
  228. * Set the correspoding property information.
  229. * @param corresponding a corresponding maker where the
  230. * isForcedCorresponding and compute methods are delegated to.
  231. */
  232. public void setCorresponding(CorrespondingPropertyMaker corresponding) {
  233. this.corresponding = corresponding;
  234. }
  235. /**
  236. * Create a new empty property. Must be overriden in compound
  237. * subclasses.
  238. * @return a new instance of the Property for which this is a maker.
  239. */
  240. public Property makeNewProperty() {
  241. return null;
  242. }
  243. /*
  244. * If the property is a relative property with a corresponding absolute
  245. * value specified, the absolute value is used. This is also true of
  246. * the inheritance priority (I think...)
  247. * If the property is an "absolute" property and it isn't specified, then
  248. * we try to compute it from the corresponding relative property: this
  249. * happens in computeProperty.
  250. */
  251. protected Property findProperty(PropertyList propertyList,
  252. boolean bTryInherit)
  253. throws FOPException
  254. {
  255. Property p = null;
  256. if (corresponding != null && corresponding.isCorrespondingForced(propertyList)) {
  257. p = corresponding.compute(propertyList);
  258. } else {
  259. p = propertyList.getExplicitBaseProp(propId);
  260. if (p == null) {
  261. p = this.compute(propertyList);
  262. }
  263. if (p == null) { // check for shorthand specification
  264. p = getShorthand(propertyList);
  265. }
  266. if (p == null && bTryInherit) {
  267. // else inherit (if has parent and is inheritable)
  268. PropertyList parentPropertyList = propertyList.getParentPropertyList();
  269. if (parentPropertyList != null && isInherited()) {
  270. p = findProperty(parentPropertyList, true);
  271. }
  272. }
  273. }
  274. return p;
  275. }
  276. /**
  277. * Return the property on the current FlowObject. Depending on the passed flags,
  278. * this will try to compute it based on other properties, or if it is
  279. * inheritable, to return the inherited value. If all else fails, it returns
  280. * the default value.
  281. * @param subpropId The subproperty id of the property being retrieved.
  282. * Is 0 when retriving a base property.
  283. * @param propertylist The PropertyList object being built for this FO.
  284. * @param bTryInherit true if inherited properties should be examined.
  285. * @param bTryDefault true if the default value should be returned.
  286. */
  287. public Property get(int subpropId, PropertyList propertyList,
  288. boolean bTryInherit, boolean bTryDefault)
  289. throws FOPException
  290. {
  291. Property p = findProperty(propertyList, bTryInherit);
  292. if (p == null && bTryDefault) { // default value for this FO!
  293. try {
  294. p = make(propertyList);
  295. } catch (FOPException e) {
  296. // don't know what to do here
  297. }
  298. }
  299. return p;
  300. }
  301. /**
  302. * Default implementation of isInherited.
  303. * @return A boolean indicating whether this property is inherited.
  304. */
  305. public boolean isInherited() {
  306. return inherited;
  307. }
  308. /**
  309. * This is used to handle properties specified as a percentage of
  310. * some "base length", such as the content width of their containing
  311. * box.
  312. * Overridden by subclasses which allow percent specifications. See
  313. * the documentation on properties.xsl for details.
  314. * @param fo the FObj containing the PercentBase
  315. * @param pl the PropertyList containing the property. (TODO: explain
  316. * what this is used for, or remove it from the signature.)
  317. * @return an object implementing the PercentBase interface.
  318. */
  319. public PercentBase getPercentBase(FObj fo, PropertyList pl) {
  320. if (percentBase == -1)
  321. return null;
  322. return new LengthBase(fo, pl, percentBase);
  323. }
  324. /**
  325. * Return a property value for the given component of a compound
  326. * property.
  327. * @param p A property value for a compound property type such as
  328. * SpaceProperty.
  329. * @param subprop The Constants ID of the component whose value is to be
  330. * returned.
  331. * NOTE: this is only to ease porting when calls are made to
  332. * PropertyList.get() using a component name of a compound property,
  333. * such as get("space.optimum"). The recommended technique is:
  334. * get("space").getOptimum().
  335. * Overridden by property maker subclasses which handle
  336. * compound properties.
  337. * @return the Property containing the subproperty
  338. */
  339. public Property getSubprop(Property p, int subpropId) {
  340. CompoundDatatype val = (CompoundDatatype) p.getObject();
  341. return val.getComponent(subpropId);
  342. }
  343. /**
  344. * Set a component in a compound property and return the modified
  345. * compound property object.
  346. * This default implementation returns the original base property
  347. * without modifying it.
  348. * It is overridden by property maker subclasses which handle
  349. * compound properties.
  350. * @param baseProp The Property object representing the compound property,
  351. * such as SpaceProperty.
  352. * @param partId The ID of the component whose value is specified.
  353. * @param subProp A Property object holding the specified value of the
  354. * component to be set.
  355. * @return The modified compound property object.
  356. */
  357. protected Property setSubprop(Property baseProp, int partId,
  358. Property subProp) {
  359. CompoundDatatype val = (CompoundDatatype) baseProp.getObject();
  360. val.setComponent(partId, subProp, false);
  361. return baseProp;
  362. }
  363. /**
  364. * Return the default value.
  365. * @param propertyList The PropertyList object being built for this FO.
  366. * @return the Property object corresponding to the parameters
  367. * @throws FOPException for invalid or inconsisten FO input
  368. */
  369. public Property make(PropertyList propertyList) throws FOPException {
  370. if (defaultProperty != null) {
  371. return defaultProperty;
  372. }
  373. Property p = make(propertyList, defaultValue, propertyList.getParentFObj());
  374. if (!contextDep) {
  375. defaultProperty = p;
  376. }
  377. return p;
  378. }
  379. /**
  380. * Create a Property object from an attribute specification.
  381. * @param propertyList The PropertyList object being built for this FO.
  382. * @param value The attribute value.
  383. * @param fo The current FO whose properties are being set.
  384. * @return The initialized Property object.
  385. * @throws FOPException for invalid or inconsistent FO input
  386. */
  387. public Property make(PropertyList propertyList, String value,
  388. FObj fo) throws FOPException {
  389. try {
  390. Property newProp = null;
  391. String pvalue = value;
  392. if ("inherit".equals(value)) {
  393. newProp = propertyList.getFromParent(this.propId);
  394. } else {
  395. newProp = checkEnumValues(value);
  396. }
  397. if (newProp == null) {
  398. /* Check for keyword shorthand values to be substituted. */
  399. pvalue = checkValueKeywords(value);
  400. // Override parsePropertyValue in each subclass of Property.Maker
  401. Property p = PropertyParser.parse(pvalue,
  402. new PropertyInfo(this,
  403. propertyList, fo));
  404. newProp = convertProperty(p, propertyList, fo);
  405. }
  406. if (newProp == null) {
  407. throw new org.apache.fop.fo.expr.PropertyException("No conversion defined");
  408. }
  409. return newProp;
  410. } catch (org.apache.fop.fo.expr.PropertyException propEx) {
  411. String propName = FOPropertyMapping.getPropertyName(this.propId);
  412. throw new FOPException("Error in " + propName
  413. + " property value '" + value + "': "
  414. + propEx);
  415. }
  416. }
  417. /**
  418. * Make a property value for a compound property. If the property
  419. * value is already partially initialized, this method will modify it.
  420. * @param baseProp The Property object representing the compound property,
  421. * for example: SpaceProperty.
  422. * @param subpropId The Constants ID of the subproperty (component)
  423. * whose value is specified.
  424. * @param propertyList The propertyList being built.
  425. * @param fo The FO whose properties are being set.
  426. * @param value the value of the
  427. * @return baseProp (or if null, a new compound property object) with
  428. * the new subproperty added
  429. * @throws FOPException for invalid or inconsistent FO input
  430. */
  431. public Property make(Property baseProp, int subpropId,
  432. PropertyList propertyList, String value,
  433. FObj fo) throws FOPException {
  434. //getLogger().error("compound property component "
  435. // + partName + " unknown.");
  436. return baseProp;
  437. }
  438. public Property convertShorthandProperty(PropertyList propertyList,
  439. Property prop, FObj fo) {
  440. Property pret = null;
  441. try {
  442. pret = convertProperty(prop, propertyList, fo);
  443. if (pret == null) {
  444. // If value is a name token, may be keyword or Enum
  445. String sval = prop.getNCname();
  446. if (sval != null) {
  447. // System.err.println("Convert shorthand ncname " + sval);
  448. pret = checkEnumValues(sval);
  449. if (pret == null) {
  450. /* Check for keyword shorthand values to be substituted. */
  451. String pvalue = checkValueKeywords(sval);
  452. if (!pvalue.equals(sval)) {
  453. // System.err.println("Convert shorthand keyword" + pvalue);
  454. // Substituted a value: must parse it
  455. Property p =
  456. PropertyParser.parse(pvalue,
  457. new PropertyInfo(this,
  458. propertyList,
  459. fo));
  460. pret = convertProperty(p, propertyList, fo);
  461. }
  462. }
  463. }
  464. }
  465. } catch (FOPException e) {
  466. //getLogger().error("convertShorthandProperty caught FOPException "
  467. // + e);
  468. } catch (org.apache.fop.fo.expr.PropertyException propEx) {
  469. //getLogger().error("convertShorthandProperty caught PropertyException "
  470. // + propEx);
  471. }
  472. if (pret != null) {
  473. /*
  474. * System.err.println("Return shorthand value " + pret.getString() +
  475. * " for " + getPropName());
  476. */
  477. }
  478. return pret;
  479. }
  480. /**
  481. * For properties that contain enumerated values.
  482. * This method should be overridden by subclasses.
  483. * @param value the string containing the property value
  484. * @return the Property encapsulating the enumerated equivalent of the
  485. * input value
  486. */
  487. protected Property checkEnumValues(String value) {
  488. if (enums != null) {
  489. return (Property) enums.get(value);
  490. }
  491. return null;
  492. }
  493. /**
  494. * Return a String to be parsed if the passed value corresponds to
  495. * a keyword which can be parsed and used to initialize the property.
  496. * For example, the border-width family of properties can have the
  497. * initializers "thin", "medium", or "thick". The FOPropertyMapping
  498. * file specifies a length value equivalent for these keywords,
  499. * such as "0.5pt" for "thin".
  500. * @param value The string value of property attribute.
  501. * @return A String containging a parseable equivalent or null if
  502. * the passed value isn't a keyword initializer for this Property.
  503. */
  504. protected String checkValueKeywords(String keyword) {
  505. if (keywords != null) {
  506. String value = (String)keywords.get(keyword);
  507. if (value != null) {
  508. return value;
  509. }
  510. }
  511. return keyword;
  512. }
  513. /**
  514. * Return a Property object based on the passed Property object.
  515. * This method is called if the Property object built by the parser
  516. * isn't the right type for this property.
  517. * It is overridden by subclasses.
  518. * @param p The Property object return by the expression parser
  519. * @param propertyList The PropertyList object being built for this FO.
  520. * @param fo The current FO whose properties are being set.
  521. * @return A Property of the correct type or null if the parsed value
  522. * can't be converted to the correct type.
  523. * @throws FOPException for invalid or inconsistent FO input
  524. */
  525. protected Property convertProperty(Property p,
  526. PropertyList propertyList,
  527. FObj fo) throws FOPException {
  528. return null;
  529. }
  530. /**
  531. * For properties that have more than one legal way to be specified,
  532. * this routine should be overridden to attempt to set them based upon
  533. * the other methods. For example, colors may be specified using an RGB
  534. * model, or they may be specified using an NCname.
  535. * @param p property whose datatype should be converted
  536. * @param propertyList collection of properties. (TODO: explain why
  537. * this is needed, or remove it from the signature.)
  538. * @param fo the FObj to which this property is attached. (TODO: explain
  539. * why this is needed, or remove it from the signature).
  540. * @return an Property with the appropriate datatype used
  541. */
  542. protected Property convertPropertyDatatype(Property p,
  543. PropertyList propertyList,
  544. FObj fo) {
  545. return null;
  546. }
  547. /**
  548. * Return a Property object representing the value of this property,
  549. * based on other property values for this FO.
  550. * A special case is properties which inherit the specified value,
  551. * rather than the computed value.
  552. * @param propertyList The PropertyList for the FO.
  553. * @return Property A computed Property value or null if no rules
  554. * are specified to compute the value.
  555. * @throws FOPException for invalid or inconsistent FO input
  556. */
  557. protected Property compute(PropertyList propertyList)
  558. throws FOPException {
  559. if (corresponding != null) {
  560. return corresponding.compute(propertyList);
  561. }
  562. return null; // standard
  563. }
  564. /**
  565. * For properties that can be set by shorthand properties, this method
  566. * should return the Property, if any, that is parsed from any
  567. * shorthand properties that affect this property.
  568. * This method expects to be overridden by subclasses.
  569. * For example, the border-right-width property could be set implicitly
  570. * from the border shorthand property, the border-width shorthand
  571. * property, or the border-right shorthand property. This method should
  572. * be overridden in the appropriate subclass to check each of these, and
  573. * return an appropriate border-right-width Property object.
  574. * @param propertyList the collection of properties to be considered
  575. * @return the Property, if found, the correspons, otherwise, null
  576. */
  577. protected Property getShorthand(PropertyList propertyList) {
  578. if (shorthands == null) {
  579. return null;
  580. }
  581. ListProperty listprop;
  582. int n = shorthands.length;
  583. for (int i = 0; i < n; i++) {
  584. Property.Maker shorthand = shorthands[i];
  585. listprop = (ListProperty)propertyList.getExplicit(shorthand.propId);
  586. if (listprop != null) {
  587. ShorthandParser parser = shorthand.datatypeParser;
  588. Property p = parser.getValueForProperty(getPropId(),
  589. listprop, this, propertyList);
  590. if (p != null) {
  591. return p;
  592. }
  593. }
  594. }
  595. return null;
  596. }
  597. /**
  598. * Return a clone of the makers. Used by useGeneric() to clone the
  599. * subproperty makers of the generic compound makers.
  600. */
  601. public Object clone() {
  602. try {
  603. return super.clone();
  604. } catch (CloneNotSupportedException exc) {
  605. return null;
  606. }
  607. }
  608. } // end of nested Maker class
  609. /**
  610. * The original specified value for properties which inherit
  611. * specified values.
  612. */
  613. private String specVal;
  614. /**
  615. * Set the original value specified for the property attribute.
  616. * @param specVal The specified value.
  617. */
  618. public void setSpecifiedValue(String specVal) {
  619. this.specVal = specVal;
  620. }
  621. /**
  622. * Return the original value specified for the property attribute.
  623. * @return The specified value as a String.
  624. */
  625. public String getSpecifiedValue() {
  626. return specVal;
  627. }
  628. /*
  629. * This section contains accessor functions for all possible Property datatypes
  630. */
  631. /**
  632. * This method expects to be overridden by subclasses
  633. * @return Length property value
  634. */
  635. public Length getLength() {
  636. return null;
  637. }
  638. /**
  639. * This method expects to be overridden by subclasses
  640. * @return ColorType property value
  641. */
  642. public ColorType getColorType() {
  643. return null;
  644. }
  645. /**
  646. * This method expects to be overridden by subclasses
  647. * @return CondLength property value
  648. */
  649. public CondLength getCondLength() {
  650. return null;
  651. }
  652. /**
  653. * This method expects to be overridden by subclasses
  654. * @return LenghtRange property value
  655. */
  656. public LengthRange getLengthRange() {
  657. return null;
  658. }
  659. /**
  660. * This method expects to be overridden by subclasses
  661. * @return LengthPair property value
  662. */
  663. public LengthPair getLengthPair() {
  664. return null;
  665. }
  666. /**
  667. * This method expects to be overridden by subclasses
  668. * @return Space property value
  669. */
  670. public Space getSpace() {
  671. return null;
  672. }
  673. /**
  674. * This method expects to be overridden by subclasses
  675. * @return Keep property value
  676. */
  677. public Keep getKeep() {
  678. return null;
  679. }
  680. /**
  681. * This method expects to be overridden by subclasses
  682. * @return integer equivalent of enumerated property value
  683. */
  684. public int getEnum() {
  685. return 0;
  686. }
  687. /**
  688. * This method expects to be overridden by subclasses
  689. * @return char property value
  690. */
  691. public char getCharacter() {
  692. return 0;
  693. }
  694. /**
  695. * This method expects to be overridden by subclasses
  696. * @return collection of other property (sub-property) objects
  697. */
  698. public Vector getList() {
  699. return null;
  700. }
  701. /**
  702. * This method expects to be overridden by subclasses
  703. * @return Number property value
  704. */
  705. public Number getNumber() {
  706. return null;
  707. }
  708. /**
  709. * This method expects to be overridden by subclasses
  710. * @return Numeric property value
  711. */
  712. public Numeric getNumeric() {
  713. return null;
  714. }
  715. /**
  716. * This method expects to be overridden by subclasses
  717. * @return NCname property value
  718. */
  719. public String getNCname() {
  720. return null;
  721. }
  722. /**
  723. * This method expects to be overridden by subclasses
  724. * @return Object property value
  725. */
  726. public Object getObject() {
  727. return null;
  728. }
  729. /**
  730. * This method expects to be overridden by subclasses.
  731. * @return String property value
  732. */
  733. public String getString() {
  734. Object o = getObject();
  735. return (o == null) ? null : o.toString();
  736. }
  737. /**
  738. * Return a string representation of the property value. Only used
  739. * for debugging.
  740. */
  741. public String toString() {
  742. return getString();
  743. }
  744. }