@Nullable protected <T> T getDefaultState(@Nonnull Object component, @Nonnull String componentName, @Nonnull final Class<T> stateClass) { URL url = DecodeDefaultsUtil.getDefaults(component, componentName); if (url == null) { return null; } try { Element documentElement = JDOMXIncluder.resolve(JDOMUtil.loadDocument(url), url.toExternalForm()).detachRootElement(); PathMacroManager pathMacroManager = getPathMacroManagerForDefaults(); if (pathMacroManager != null) { pathMacroManager.expandPaths(documentElement); } return DefaultStateSerializer.deserializeState(documentElement, stateClass, null); } catch (IOException | JDOMException e) { throw new StateStorageException("Error loading state from " + url, e); } }
private static XmlTag[] extractXpointer(@NotNull XmlTag rootTag, @Nullable final String xpointer) { if (xpointer != null) { Matcher matcher = JDOMXIncluder.XPOINTER_PATTERN.matcher(xpointer); if (matcher.matches()) { String pointer = matcher.group(1); matcher = JDOMXIncluder.CHILDREN_PATTERN.matcher(pointer); if (matcher.matches() && matcher.group(1).equals(rootTag.getName())) { return rootTag.getSubTags(); } } } return new XmlTag[]{rootTag}; }
public void readExternal(@NotNull Document document, @NotNull URL url, boolean ignoreMissingInclude) throws InvalidDataException, FileNotFoundException { document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude); Element rootElement = document.getRootElement(); JDOMUtil.internElement(rootElement, new StringInterner()); readExternal(document.getRootElement()); }
public void readExternal(@NotNull Document document, @NotNull URL url) throws InvalidDataException, FileNotFoundException { document = JDOMXIncluder.resolve(document, url.toExternalForm()); Element rootElement = document.getRootElement(); internJDOMElement(rootElement); readExternal(document.getRootElement()); }
public void readExternal(@Nonnull Document document, @Nonnull URL url, boolean ignoreMissingInclude) throws InvalidDataException, FileNotFoundException { document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude); Element rootElement = document.getRootElement(); JDOMUtil.internStringsInElement(rootElement, new StringInterner()); readExternal(document.getRootElement()); }