MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / SvgElementFactory

Class SvgElementFactory

src/main/java/org/htmlunit/svg/SvgElementFactory.java:36–137  ·  view source on GitHub ↗

Element factory which creates elements by calling the constructor on a given org.htmlunit.svg.SvgElement subclass. @author Ahmed Ashour @author Frank Danek @author Ronald Brill

Source from the content-addressed store, hash-verified

34 * @author Ronald Brill
35 */
36public class SvgElementFactory implements ElementFactory {
37
38 private static final Class<?>[] CLASSES_ = {SvgAltGlyph.class, SvgAltGlyphDef.class, SvgAltGlyphItem.class,
39 SvgAnchor.class, SvgAnimate.class, SvgAnimateColor.class, SvgAnimateMotion.class, SvgAnimateTransform.class,
40 SvgCircle.class, SvgClipPath.class, SvgColorProfile.class, SvgCursor.class, SvgDefs.class, SvgDesc.class,
41 SvgEllipse.class, SvgFeBlend.class, SvgFeColorMatrix.class, SvgFeComponentTransfer.class,
42 SvgFeComposite.class, SvgFeConvolveMatrix.class, SvgFeDiffuseLighting.class, SvgFeDisplacementMap.class,
43 SvgFeDistantLight.class, SvgFeFlood.class, SvgFeFuncA.class, SvgFeFuncB.class, SvgFeFuncG.class,
44 SvgFeFuncR.class, SvgFeGaussianBlur.class, SvgFeImage.class, SvgFeMerge.class, SvgFeMergeNode.class,
45 SvgFeMorphology.class, SvgFeOffset.class, SvgFePointLight.class, SvgFeSpecularLighting.class,
46 SvgFeSpotLight.class, SvgFeTile.class, SvgFeTurbulence.class, SvgFilter.class, SvgFont.class,
47 SvgFontFace.class, SvgFontFaceFormat.class, SvgFontFaceName.class, SvgFontFaceSrc.class,
48 SvgFontFaceURI.class, SvgForeignObject.class, SvgGlyph.class, SvgGlyphRef.class, SvgGroup.class,
49 SvgHKern.class, SvgImage.class, SvgLine.class, SvgLinearGradient.class, SvgMarker.class, SvgMask.class,
50 SvgMetadata.class, SvgMissingGlyph.class, SvgMPath.class, SvgPath.class, SvgPattern.class, SvgPolygon.class,
51 SvgPolyline.class, SvgRadialGradient.class, SvgRect.class, SvgScript.class, SvgSet.class, SvgStop.class,
52 SvgStyle.class, SvgSwitch.class, SvgSymbol.class, SvgText.class, SvgTextPath.class,
53 SvgTitle.class, SvgTRef.class, SvgTSpan.class, SvgUse.class, SvgView.class, SvgVKern.class
54 };
55
56 private static final Map<String, Class<?>> ELEMENTS_ = new ConcurrentHashMap<>();
57
58 static {
59 try {
60 for (final Class<?> klass : CLASSES_) {
61 final String key = klass.getField("TAG_NAME").get(null).toString();
62 ELEMENTS_.put(StringUtils.toRootLowerCase(key), klass);
63 }
64 }
65 catch (final Exception e) {
66 throw new IllegalStateException(e);
67 }
68 }
69
70 /**
71 * {@inheritDoc}
72 */
73 @Override
74 public DomElement createElement(final SgmlPage page, final String tagName, final Attributes attributes) {
75 throw new IllegalStateException("SVG.createElement not yet implemented!");
76 }
77
78 /**
79 * {@inheritDoc}
80 */
81 @Override
82 public DomElement createElementNS(final SgmlPage page, final String namespaceURI, String qualifiedNameLC,
83 final Attributes attributes) {
84
85 final Map<String, DomAttr> attributeMap = toMap(page, attributes);
86 qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedNameLC);
87 String tagNameLC = qualifiedNameLC;
88 if (tagNameLC.indexOf(':') != -1) {
89 tagNameLC = tagNameLC.substring(tagNameLC.indexOf(':') + 1);
90 }
91 DomElement element = null;
92
93 final Class<?> klass = ELEMENTS_.get(tagNameLC);

Callers

nothing calls this directly

Calls 5

toRootLowerCaseMethod · 0.95
getFieldMethod · 0.80
toStringMethod · 0.45
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…