use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.
the class VersionedSchemaDefaultValueService method compute.
@Override
protected String compute() {
String version = _defaultVersion;
Resource elementResource = context(Element.class).resource();
RootXmlResource resource = elementResource.adapt(RootXmlResource.class);
if (resource != null) {
Document document = resource.getDomDocument();
if (document != null) {
Node node = document.getDocumentElement();
if (node != null) {
String namespace = node.getNamespaceURI();
Matcher matcher = _namespacePattern.matcher(namespace);
if (matcher.matches()) {
version = matcher.group(1);
}
}
}
}
return version.replaceAll(StringPool.UNDERSCORE, ".");
}
use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.
the class VersionedDTDDefaultValueService method compute.
@Override
protected String compute() {
String defaultVersion = null;
Resource resource = context(Element.class).resource();
RootXmlResource xmlResource = resource.adapt(RootXmlResource.class);
if (xmlResource != null) {
Document document = xmlResource.getDomDocument();
if ((document != null) && (document.getDoctype() != null)) {
String systemId = document.getDoctype().getSystemId();
Matcher matcher = _systemIdPattern.matcher(systemId);
if (matcher.matches()) {
defaultVersion = matcher.group(1);
}
}
}
if (defaultVersion == null) {
// default should be 6.0.0
defaultVersion = "6.0.0";
}
return defaultVersion.replaceAll(StringPool.UNDERSCORE, ".");
}
Aggregations