public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?flintstones.helper.data.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,17 @@
|
||||
<?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.valuation.linguistic</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Linguistic</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.valuation.linguistic</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>1779484362746</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,21 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Linguistic
|
||||
Bundle-SymbolicName: flintstones.valuation.linguistic;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.entity.valuation;visibility:=reexport,
|
||||
flintstones.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.entity.domain,
|
||||
flintstones.domain.fuzzyset;visibility:=reexport,
|
||||
flintstones.helper.validator,
|
||||
flintstones.helper.data,
|
||||
org.eclipse.e4.core.contexts,
|
||||
javax.inject,
|
||||
org.apache.commons.lang,
|
||||
org.eclipse.e4.core.di,
|
||||
javax.annotation
|
||||
Export-Package: flintstones.valuation.linguistic
|
||||
Automatic-Module-Name: flintstones.valuation.linguistic
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.valuation">
|
||||
<valuation
|
||||
domain="flintstones.domain.linguistic"
|
||||
uid="flintstones.valuation.linguistic"
|
||||
implementation="flintstones.valuation.linguistic.LinguisticValuation"
|
||||
is_intermediate="false"
|
||||
name="Linguistic">
|
||||
</valuation>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
|
||||
|
||||
package flintstones.valuation.linguistic;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
import flintstones.helper.validator.Validator;
|
||||
import flintstones.valuation.linguistic.messages.Messages;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class LinguisticValuation extends Valuation {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
public static final String ID = "flintstones.valuation.linguistic"; //$NON-NLS-1$
|
||||
|
||||
public LabelLinguisticDomain _label;
|
||||
|
||||
public LinguisticValuation() {
|
||||
super();
|
||||
setId(ID);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
this._label = ContextInjectionFactory.make(LabelLinguisticDomain.class, this.context);
|
||||
}
|
||||
|
||||
public enum FieldsFS3 implements ExtensionEnum {
|
||||
labelvaluation, label
|
||||
}
|
||||
|
||||
public enum Fields implements ExtensionEnum {
|
||||
labelValuation, label, labelValuations
|
||||
}
|
||||
|
||||
public void setLabel(int pos) {
|
||||
LabelLinguisticDomain label = ((FuzzySet) this.domain).getLabelSet()
|
||||
.getLabel(pos);
|
||||
Validator.notNull(label);
|
||||
|
||||
this._label = label;
|
||||
}
|
||||
|
||||
public void setLabel(String name) {
|
||||
LabelLinguisticDomain label = ((FuzzySet) this.domain).getLabelSet()
|
||||
.getLabel(name);
|
||||
Validator.notNull(label);
|
||||
|
||||
this._label = label;
|
||||
}
|
||||
|
||||
public void setLabel(LabelLinguisticDomain label) {
|
||||
Validator.notNull(label);
|
||||
|
||||
if (((FuzzySet) this.domain).getLabelSet()
|
||||
.containsLabel(label))
|
||||
this._label = label;
|
||||
else
|
||||
throw new IllegalArgumentException(this.messages.LinguisticValuation_Not_contains_indomain);
|
||||
}
|
||||
|
||||
public LabelLinguisticDomain getLabel() {
|
||||
return this._label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Valuation negateValuation() {
|
||||
LinguisticValuation result = (LinguisticValuation) this.clone();
|
||||
|
||||
FuzzySet fdomain = (FuzzySet) this.domain;
|
||||
if (fdomain.getLabelSet()
|
||||
.getCardinality() > 1) {
|
||||
int negPos = (fdomain.getLabelSet()
|
||||
.getCardinality() - 1) - fdomain.getLabelSet()
|
||||
.getPos(this._label);
|
||||
result.setLabel(negPos);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeFormatValuationToString() {
|
||||
return this._label.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (this._label + " in " + this.domain.toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
LinguisticValuation other = (LinguisticValuation) obj;
|
||||
EqualsBuilder eb = new EqualsBuilder();
|
||||
eb.append(this.domain, other.domain);
|
||||
eb.append(this._label, other._label);
|
||||
|
||||
return eb.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Valuation other) {
|
||||
Validator.notNull(other);
|
||||
Validator.notIllegalElementType(other, new String[] { LinguisticValuation.class.toString() });
|
||||
|
||||
if (this.domain.equals(other.getDomain()))
|
||||
return this._label.compareTo(((LinguisticValuation) other)._label);
|
||||
throw new IllegalArgumentException(this.messages.LinguisticValuation_Differentdomains);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder hcb = new HashCodeBuilder(17, 31);
|
||||
hcb.append(this.domain);
|
||||
hcb.append(this._label);
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
Object result = null;
|
||||
|
||||
result = super.clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer) throws XMLStreamException {
|
||||
writer.writeStartElement(Fields.labelValuations.toString());
|
||||
this.writeLabel(writer);
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
private void writeLabel(XMLStreamWriter writer) throws XMLStreamException {
|
||||
writer.writeStartElement(Fields.labelValuation.toString());
|
||||
writer.writeAttribute(Fields.label.toString(), this._label.getName());
|
||||
this._label.write(writer);
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(WNode node) {
|
||||
|
||||
if (node.getVersion()
|
||||
.equals("3.0")) //$NON-NLS-1$
|
||||
this.readFS3(node);
|
||||
else
|
||||
this.readFS4(node);
|
||||
|
||||
}
|
||||
|
||||
private void readFS3(WNode node) {
|
||||
WNode n1node = node.getFirst(FieldsFS3.labelvaluation);
|
||||
WNode n2node = n1node.getFirstByAttribute(FieldsFS3.label); // Labelv label="xxxx", L label="L", etc.
|
||||
|
||||
String name = n2node.getAttribute(FieldsFS3.label);
|
||||
this._label = ContextInjectionFactory.make(LabelLinguisticDomain.class, this.context);
|
||||
this._label.setName(name);
|
||||
this._label.read(n2node);
|
||||
}
|
||||
|
||||
private void readFS4(WNode node) {
|
||||
WNode n1node = node.getFirst(Fields.labelValuations);
|
||||
WNode n2node = n1node.getFirstByAttribute(Fields.label); // Labelv label="xxxx", L label="L", etc.
|
||||
|
||||
String name = n2node.getAttribute(Fields.label);
|
||||
this._label = ContextInjectionFactory.make(LabelLinguisticDomain.class, this.context);
|
||||
this._label.setName(name);
|
||||
this._label.read(n2node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFromString(String value) {
|
||||
|
||||
boolean isNumber = true;
|
||||
try {
|
||||
Double.parseDouble(value);
|
||||
} catch (NumberFormatException e) {
|
||||
isNumber = false;
|
||||
}
|
||||
|
||||
if(isNumber) {
|
||||
int pos = DoubleHelper.ParseDouble(value).intValue();
|
||||
setLabel(pos);
|
||||
// throw new UnsupportedOperationException("Implementar, debería recibir la etiqueta y setearla");
|
||||
} else {
|
||||
setLabel(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.valuation.linguistic.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String LinguisticValuation_Not_contains_indomain;
|
||||
public String LinguisticValuation_Not_BLTS_fuzzy_set;
|
||||
public String LinguisticValuation_Differentdomains;
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Different_domains=Different domains
|
||||
Not_BLTS_fuzzy_set=Not BLTS fuzzy set.
|
||||
Not_contains_in_domain=Label not contained in domain.
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Different_domains=Diferentes dominios
|
||||
Not_BLTS_fuzzy_set=No BLTS fuzzy establecido.
|
||||
Not_contains_in_domain=La etiqueta no pertenece al dominio
|
||||
Reference in New Issue
Block a user