1 51 package org.apache.fop.fo; 52 53 import org.apache.fop.datatypes.*; 55 import org.apache.fop.fo.expr.Numeric; 56 import org.apache.fop.fo.expr.PropertyParser; 57 import org.apache.fop.fo.expr.PropertyInfo; 58 import org.apache.fop.apps.FOPException; 59 60 import org.apache.avalon.framework.logger.Logger; 62 63 import java.util.ArrayList ; 65 66 public class Property { 67 68 public static class Maker { 69 private static final String UNKNOWN = "UNKNOWN"; 70 private String propName; 71 72 75 protected String getPropName() { 76 return propName; 77 } 78 79 83 protected Maker(String propName) { 84 this.propName = propName; 85 } 86 87 91 protected Maker() { 92 this.propName = UNKNOWN; 93 } 94 95 96 100 public boolean isInherited() { 101 return false; 102 } 103 104 110 public boolean inheritsSpecified() { 111 return false; 112 } 113 114 115 123 public PercentBase getPercentBase(FObj fo, PropertyList pl) { 124 return null; 125 } 126 127 136 protected Maker getSubpropMaker(String subprop) { 137 return null; 138 } 139 140 154 public Property getSubpropValue(Property p, String subprop) { 155 return null; 156 } 157 158 168 public Property make(Property baseProp, String partName, 169 PropertyList propertyList, String value, 170 FObj fo) throws FOPException { 171 if (baseProp == null) { 172 baseProp = makeCompound(propertyList, fo); 173 } 174 Maker spMaker = getSubpropMaker(partName); 175 if (spMaker != null) { 176 Property p = spMaker.make(propertyList, value, fo); 177 if (p != null) { 178 return setSubprop(baseProp, partName, p); 179 } 180 } else { 181 } 184 return baseProp; 185 } 186 187 201 protected Property setSubprop(Property baseProp, String partName, 202 Property subProp) { 203 return baseProp; 204 } 205 206 213 public Property make(PropertyList propertyList, String value, 214 FObj fo) throws FOPException { 215 try { 216 Property pret = null; 217 String pvalue = value; 218 pret = checkEnumValues(value); 219 if (pret == null) { 220 221 pvalue = checkValueKeywords(value); 222 Property p = PropertyParser.parse(pvalue, 224 new PropertyInfo(this, 225 propertyList, fo)); 226 pret = convertProperty(p, propertyList, fo); 227 } else if (isCompoundMaker()) { 228 pret = convertProperty(pret, propertyList, fo); 229 } 230 if (pret == null) { 231 throw new org.apache.fop.fo.expr.PropertyException("No conversion defined"); 232 } else if (inheritsSpecified()) { 233 pret.setSpecifiedValue(pvalue); 234 } 235 return pret; 236 } catch (org.apache.fop.fo.expr.PropertyException propEx) { 237 throw new FOPException("Error in " + propName + 238 " property value '" + value + "': " + 239 propEx); 240 } 241 } 242 243 public Property convertShorthandProperty(PropertyList propertyList, 244 Property prop, FObj fo) { 245 Property pret = null; 246 try { 247 pret = convertProperty(prop, propertyList, fo); 248 if (pret == null) { 249 String sval = prop.getNCname(); 251 if (sval != null) { 252 pret = checkEnumValues(sval); 254 if (pret == null) { 255 256 String pvalue = checkValueKeywords(sval); 257 if (!pvalue.equals(sval)) { 258 Property p = 261 PropertyParser.parse(pvalue, 262 new PropertyInfo(this, 263 propertyList, 264 fo)); 265 pret = convertProperty(p, propertyList, fo); 266 } 267 } 268 } 269 } 270 } catch (FOPException e) { 271 272 } catch (org.apache.fop.fo.expr.PropertyException propEx) { 275 } 278 if (pret != null) { 279 283 } 284 return pret; 285 } 286 287 protected boolean isCompoundMaker() { 288 return false; 289 } 290 291 public Property checkEnumValues(String value) { 292 return null; 293 } 294 295 308 protected String checkValueKeywords(String value) { 309 return value; 310 } 311 312 324 public Property convertProperty(Property p, 325 PropertyList propertyList, 326 FObj fo) throws FOPException { 327 return null; 328 } 329 330 protected Property convertPropertyDatatype(Property p, 331 PropertyList propertyList, 332 FObj fo) { 333 return null; 334 } 335 336 340 public Property make(PropertyList propertyList) throws FOPException { 341 return null; 342 } 343 344 351 protected Property makeCompound(PropertyList propertyList, 352 FObj parentFO) throws FOPException { 353 return null; 354 } 355 356 365 public Property compute(PropertyList propertyList) 366 throws FOPException { 367 if (inheritsSpecified()) { 368 Property specProp = 372 propertyList.getNearestSpecified(propName); 373 if (specProp != null) { 374 String specVal = specProp.getSpecifiedValue(); 376 if (specVal != null) { 377 try { 378 return make(propertyList, specVal, 379 propertyList.getParentFObj()); 380 } catch (FOPException e) { 381 return null; 385 } 386 } 387 } 388 } 389 return null; } 391 392 public boolean isCorrespondingForced(PropertyList propertyList) { 393 return false; 394 } 395 396 public Property getShorthand(PropertyList propertyList) { 397 return null; 398 } 399 400 } 402 406 private String specVal; 407 408 protected Logger log; 409 410 public void setLogger(Logger logger) { 411 log = logger; 412 } 413 414 418 public void setSpecifiedValue(String specVal) { 419 this.specVal = specVal; 420 } 421 422 426 public String getSpecifiedValue() { 427 return specVal; 428 } 429 430 433 public Length getLength() { 434 return null; 435 } 436 437 public ColorType getColorType() { 438 return null; 439 } 440 441 public CondLength getCondLength() { 442 return null; 443 } 444 445 public LengthRange getLengthRange() { 446 return null; 447 } 448 449 public LengthPair getLengthPair() { 450 return null; 451 } 452 453 public Space getSpace() { 454 return null; 455 } 456 457 public Keep getKeep() { 458 return null; 459 } 460 461 public int getEnum() { 462 return 0; 463 } 464 465 public char getCharacter() { 466 return 0; 467 } 468 469 public ArrayList getList() { 470 return null; 471 } 473 public Number getNumber() { 474 return null; 475 } 476 477 public Numeric getNumeric() { 479 return null; 480 } 481 482 public String getNCname() { 483 return null; 484 } 485 486 public Object getObject() { 487 return null; 488 } 489 490 public String getString() { 491 Object o = getObject(); 492 return (o == null) ? null : o.toString(); 493 } 494 495 } 496 | Popular Tags |