public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>flintstones.group</groupId>
<artifactId>flintstones.bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>flintstones.helper.data.wxml</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Wxml</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.helper.data.wxml</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1779484362608</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Wxml
Bundle-SymbolicName: flintstones.helper.data.wxml
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.helper.data.wxml
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: flintstones.helper.data.wxml,
flintstones.helper.data.wxml.exception
Require-Bundle: flintstones.entity.extensionenum;visibility:=reexport
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,290 @@
package flintstones.helper.data.wxml;
import java.text.MessageFormat;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.helper.data.wxml.exception.WNodeNotFound;
/**
* Wrapper Node
* A Wrapper for w3c.Element and w3c.Node
*/
public class WNode {
/** The node. */
private Element node;
/** The version. */
private String version;
/**
* Instantiates a new wnode.
*
* @param enode the enode
*/
public WNode(Element enode) {
this.node = enode;
}
/**
* Instantiates a new wnode.
*
* @param nnode the nnode
*/
public WNode(Node nnode) {
if (nnode instanceof Element)
this.node = (Element) nnode;
else
throw new Error("Clase incorrecta"); //$NON-NLS-1$
}
/**
* Gets the children for the given node.
*
* @return the children
*/
public List<WNode> getChildren() {
Stream<Node> stream = IntStream.range(0, this.node.getChildNodes()
.getLength())
.mapToObj(this.node.getChildNodes()::item);
return stream.filter(x -> x instanceof Element)
.map(y -> this.withVersion(new WNode(y)))
.collect(Collectors.toList());
}
/* (non-Javadoc)
*
* @see java.lang.Object#toString() */
@Override
public String toString() {
String template = "[{0}] {1}, {2}"; //$NON-NLS-1$
String line = MessageFormat.format(template, this.version, this.node.getNodeName(), this.node.hasAttribute("id") ? this.node.getAttribute("id") : "") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
.toString();
return line;
}
/**
* Gets the attribute as int.
*
* @param key the key
* @return the attribute int
*/
public int getAttributeInt(ExtensionEnum key) {
return Integer.valueOf(this.getAttribute(key)
.replace(".0", "")); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Gets the attribute as int.
*
* @param key the key
* @return the attribute int
*/
public int getAttributeInt(String key) {
return Integer.valueOf(this.getAttribute(key));
}
/**
* Gets the attribute as int.
*
* @param key the key
* @return the attribute int
*/
public boolean getAttributeBoolean(ExtensionEnum key) {
return getAttributeBoolean(key.toString());
}
/**
* Gets the attribute as int.
*
* @param key the key
* @return the attribute int
*/
public boolean getAttributeBoolean(String key) {
return this.getAttribute(key).equals("true");
}
/**
* Gets the attribute as string.
*
* @param key the key
* @return the attribute
*/
public String getAttribute(ExtensionEnum key) {
return this.getAttribute(key.toString());
}
/**
* Gets the attribute as string.
*
* @param key the key
* @return the attribute
*/
public String getAttribute(String key) {
return this.node.getAttribute(key) != "" ? this.node.getAttribute(key) : null; //$NON-NLS-1$
}
/**
* Gets the name of the node.
*
* @return the name
*/
public String getName() {
return this.node.getNodeName();
}
/**
* Checks for a given attribute.
*
* @param key the key
* @return true, if successful
*/
public boolean hasAttribute(String key) {
return this.node.hasAttribute(key);
}
/**
* Checks for child.
*
* @return true, if successful
*/
public boolean hasChild() {
return this.node.hasChildNodes();
}
/**
* Gets the first child with the given name or null.
*
* @param nodeName the nodeName
* @return the first
*/
public WNode getFirst(ExtensionEnum nodeName) {
WNode item = this.getFirst(nodeName.toString());
return this.withVersion(item);
}
/**
* Gets the first child with the given name or null.
*
* @param nodeName the node name
* @return the first
*/
public WNode getFirst(String nodeName) {
for (int i = 0; i < this.node.getChildNodes()
.getLength(); i++)
if (this.node.getChildNodes()
.item(i) instanceof Element) {
WNode item = new WNode(this.node.getChildNodes()
.item(i));
if (item.getName()
.equals(nodeName))
return this.withVersion(item);
}
return null;
}
/**
* Gets the first child with the given name that has the given value.
*
* @param attributeKey the attribute key
* @param attributeValue the attribute value
* @return the first
* @throws WNodeNotFound
*/
public WNode getFirst(String attributeKey, String attributeValue) throws WNodeNotFound {
for (int i = 0; i < this.node.getChildNodes()
.getLength(); i++)
if (this.node.getChildNodes()
.item(i) instanceof Element) {
WNode item = new WNode(this.node.getChildNodes()
.item(i));
if (!item.hasAttribute(attributeKey))
continue;
if (item.getAttribute(attributeKey)
.equals(attributeValue))
return this.withVersion(item);
}
throw new WNodeNotFound(attributeKey, attributeValue);
}
/**
* Gets the first child with the given attribute.
*
* @param attributeKey the attribute key
* @return the first by attribute
*/
public WNode getFirstByAttribute(ExtensionEnum attributeKey) {
return this.getFirstByAttribute(attributeKey.toString());
}
/**
* Gets the first child with the given attribute.
*
* @param attributeKey the attribute key
* @return the first by attribute
*/
public WNode getFirstByAttribute(String attributeKey) {
for (int i = 0; i < this.node.getChildNodes()
.getLength(); i++)
if (this.node.getChildNodes()
.item(i) instanceof Element) {
WNode item = new WNode(this.node.getChildNodes()
.item(i));
if (item.hasAttribute(attributeKey))
return this.withVersion(item);
}
throw new Error("No encontrado el elemento con atributo" + attributeKey);//$NON-NLS-1$
}
/**
* Spread the wnode version attribute across child nodes.
*
* @param node the node
* @return the w node
*/
private WNode withVersion(WNode node) {
if (node != null)
node.setVersion(this.getVersion());
return node;
}
/**
* Gets the version attribute.
*
* @return the version
*/
public String getVersion() {
return this.version;
}
/**
* Sets the version attribute.
*
* @param version the new version
*/
public void setVersion(String version) {
this.version = version;
}
}
@@ -0,0 +1,21 @@
package flintstones.helper.data.wxml.exception;
/**
* The Class WNodeNotFound.
*/
public class WNodeNotFound extends Exception {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new w node not found.
*
* @param key the key
* @param value the value
*/
public WNodeNotFound(String key, String value) {
super("No se encuentra el elemento " + key + " => " + value);
}
}