Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
a4959554
Commit
a4959554
authored
15 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
- declared all SyntaxElements in one file to be used by the whole API
parent
da65041e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fr/inrialpes/exmo/align/parser/SyntaxElement.java
+301
-0
301 additions, 0 deletions
src/fr/inrialpes/exmo/align/parser/SyntaxElement.java
with
301 additions
and
0 deletions
src/fr/inrialpes/exmo/align/parser/SyntaxElement.java
0 → 100644
+
301
−
0
View file @
a4959554
/*
* $Id$
*
* Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck
* Copyright (C) 2005 Digital Enterprise Research Insitute (DERI) Galway
* Sourceforge version 1.6 - 2008 - then OmwgElement
* Copyright (C) INRIA, 2008-2009
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
fr.inrialpes.exmo.align.parser
;
import
java.util.HashMap
;
import
java.util.Map
;
import
fr.inrialpes.exmo.align.impl.Namespace
;
import
org.semanticweb.owl.align.AlignmentException
;
/**
* <p>
* Defines all the elements which might show up in a mapping document. Here are
* also the string representations for the different elements defined.
* </p>
* <p>
* $Id: OmwgElement.java,v 1.6 2008/01/26 16:24:58 jeuzenat Exp $
* </p>
*
* @author richi
* @version $Revision: 1.6 $
* @date $Date$
*/
public
enum
SyntaxElement
{
// RDF NAMESPACE
RDF
(
Namespace
.
RDF
,
"RDF"
,
true
),
// This is not a resource, nor a property
RDF_ABOUT
(
Namespace
.
RDF
,
"about"
),
RDF_DATATYPE
(
Namespace
.
RDF
,
"datatype"
),
RDF_PARSETYPE
(
Namespace
.
RDF
,
"parseType"
),
RDF_RESOURCE
(
Namespace
.
RDF
,
"resource"
),
// DUBLINCORE NAMESPACE
CREATOR
(
Namespace
.
DUBLIN_CORE
,
"creator"
),
DATE
(
Namespace
.
DUBLIN_CORE
,
"date"
),
IDENTIFIER
(
Namespace
.
DUBLIN_CORE
,
"identifier"
),
// ALIGNMENT NAMESPACE
ALIGNMENT
(
Namespace
.
ALIGNMENT
,
"Alignment"
,
true
),
ALID
(
Namespace
.
ALIGNMENT
,
"id"
),
CELL
(
Namespace
.
ALIGNMENT
,
"Cell"
,
true
),
CERTIFICATE
(
Namespace
.
ALIGNMENT
,
"certificate"
),
FORMALISM
(
Namespace
.
ALIGNMENT
,
"Formalism"
,
true
),
FORMATT
(
Namespace
.
ALIGNMENT
,
"formalism"
),
CELLID
(
Namespace
.
ALIGNMENT
,
"id"
),
LEVEL
(
Namespace
.
ALIGNMENT
,
"level"
),
LIMITATIONS
(
Namespace
.
ALIGNMENT
,
"limitations"
),
MAP
(
Namespace
.
ALIGNMENT
,
"map"
),
MAPPING_SOURCE
(
Namespace
.
ALIGNMENT
,
"onto1"
),
MAPPING_TARGET
(
Namespace
.
ALIGNMENT
,
"onto2"
),
MEASURE
(
Namespace
.
ALIGNMENT
,
"measure"
),
METHOD
(
Namespace
.
ALIGNMENT
,
"method"
),
NAME
(
Namespace
.
ALIGNMENT
,
"name"
),
PURPOSE
(
Namespace
.
ALIGNMENT
,
"purpose"
),
RULE_RELATION
(
Namespace
.
ALIGNMENT
,
"relation"
),
SEMANTICS
(
Namespace
.
ALIGNMENT
,
"semantics"
),
ENTITY1
(
Namespace
.
ALIGNMENT
,
"entity1"
),
ENTITY2
(
Namespace
.
ALIGNMENT
,
"entity2"
),
TIME
(
Namespace
.
ALIGNMENT
,
"time"
),
TYPE
(
Namespace
.
ALIGNMENT
,
"type"
),
URI
(
Namespace
.
ALIGNMENT
,
"uri"
),
XML
(
Namespace
.
ALIGNMENT
,
"xml"
),
ONTOLOGY
(
Namespace
.
ALIGNMENT
,
"Ontology"
,
true
),
LOCATION
(
Namespace
.
ALIGNMENT
,
"location"
),
// EDOAL NAMESPACE
AND
(
Namespace
.
EDOAL
,
"and"
,
Constructor
.
AND
),
APPLY
(
Namespace
.
EDOAL
,
"Apply"
,
true
),
ARGUMENTS
(
Namespace
.
EDOAL
,
"arguments"
),
ATTR_TRANSF
(
Namespace
.
EDOAL
,
"transf"
),
CLASS_EXPR
(
Namespace
.
EDOAL
,
"Class"
,
true
),
//ALIGNMENT
CODOMAIN_RESTRICTION
(
Namespace
.
EDOAL
,
"CodomainRestriction"
,
true
),
COMPARATOR
(
Namespace
.
EDOAL
,
"comparator"
),
COMPOSE
(
Namespace
.
EDOAL
,
"compose"
,
Constructor
.
COMP
),
DATATYPE
(
Namespace
.
EDOAL
,
"datatype"
),
DOMAIN_RESTRICTION
(
Namespace
.
EDOAL
,
"DomainRestriction"
,
true
),
FIRST
(
Namespace
.
EDOAL
,
"first"
),
ID
(
Namespace
.
EDOAL
,
"Id"
,
true
),
// Useless
INSTANCE_EXPR
(
Namespace
.
EDOAL
,
"Instance"
,
true
),
INVERSE
(
Namespace
.
EDOAL
,
"inverse"
,
Constructor
.
INVERSE
),
NEXT
(
Namespace
.
EDOAL
,
"next"
),
NOT
(
Namespace
.
EDOAL
,
"not"
,
Constructor
.
NOT
),
ONPROPERTY
(
Namespace
.
EDOAL
,
"onProperty"
),
OR
(
Namespace
.
EDOAL
,
"or"
,
Constructor
.
OR
),
PARAMETERS
(
Namespace
.
EDOAL
,
"parameters"
),
PATH
(
Namespace
.
EDOAL
,
"Path"
,
true
),
PROPERTIES
(
Namespace
.
EDOAL
,
"properties"
),
PROPERTY
(
Namespace
.
EDOAL
,
"Property"
,
true
),
PROPERTY_EXPR
(
Namespace
.
EDOAL
,
"Property"
),
// ??
PROPERTY_OCCURENCE_COND
(
Namespace
.
EDOAL
,
"PropertyOccurenceRestriction"
,
true
),
PROPERTY_TYPE_COND
(
Namespace
.
EDOAL
,
"PropertyTypeRestriction"
,
true
),
PROPERTY_VALUE_COND
(
Namespace
.
EDOAL
,
"PropertyValueRestriction"
,
true
),
REFLEXIVE
(
Namespace
.
EDOAL
,
"reflexive"
,
Constructor
.
REFLEXIVE
),
RELATION_EXPR
(
Namespace
.
EDOAL
,
"Relation"
,
true
),
//RESTRICTION(Namespace.EDOAL, "Restriction"),
SERVICE
(
Namespace
.
EDOAL
,
"service"
),
SYMMETRIC
(
Namespace
.
EDOAL
,
"symmetric"
,
Constructor
.
SYMMETRIC
),
TOCLASS
(
Namespace
.
EDOAL
,
"toClass"
),
TRANSF
(
Namespace
.
EDOAL
,
"transf"
),
TRANSITIVE
(
Namespace
.
EDOAL
,
"transitive"
,
Constructor
.
TRANSITIVE
),
TYPE_COND
(
Namespace
.
EDOAL
,
"TypeRestriction"
,
true
),
VALUE
(
Namespace
.
EDOAL
,
"value"
),
VALUE_COND
(
Namespace
.
EDOAL
,
"ValueRestriction"
,
true
)
;
/** Operator to determine how to combine the expressions */
public
enum
Constructor
{
AND
,
OR
,
NOT
,
COMP
,
JOIN
,
SYMMETRIC
,
REFLEXIVE
,
TRANSITIVE
,
INVERSE
};
private
static
Map
<
String
,
SyntaxElement
>
register
;
/** Holds the xml name for the element. */
public
final
String
name
;
/** Holds the namespace for the element. */
public
final
Namespace
namespace
;
/** Holds the corresponding operator in the . */
public
final
Constructor
operator
;
/** Holds the RDF Resource or property for the entity
* This is to be used by the RDF parser.
*/
public
Object
resource
;
/** If the resource is a property.
*/
public
final
boolean
isProperty
;
private
static
void
recordElement
(
final
String
name
,
final
SyntaxElement
el
)
{
if
(
register
==
null
)
register
=
new
HashMap
<
String
,
SyntaxElement
>();
register
.
put
(
name
,
el
);
}
/**
* Constructor which takes the name and the namespace of the element.
*
* @param namespace
* for the element
* @param name
* for the element
* @throws NullPointerException
* if the name or the namespace is <code>null</code>
*/
private
SyntaxElement
(
final
Namespace
ns
,
final
String
name
,
final
Constructor
op
,
final
boolean
prp
)
{
if
((
name
==
null
)
||
(
ns
==
null
))
{
throw
new
NullPointerException
(
"The name and the namespace must not be null"
);
}
namespace
=
ns
;
this
.
name
=
name
;
isProperty
=
prp
;
operator
=
op
;
recordElement
(
name
,
this
);
}
private
SyntaxElement
(
final
Namespace
namespace
,
final
String
name
)
{
this
(
namespace
,
name
,
(
Constructor
)
null
,
true
);
}
private
SyntaxElement
(
final
Namespace
namespace
,
final
String
name
,
final
boolean
prp
)
{
this
(
namespace
,
name
,
(
Constructor
)
null
,
prp
);
}
private
SyntaxElement
(
final
Namespace
namespace
,
final
String
name
,
final
Constructor
op
)
{
// constructors are properties...
this
(
namespace
,
name
,
op
,
true
);
}
/**
* Determines an element given on a name string. The search will be
* case-sensitive.
* Good morning efficiency...
*
* @param s
* the string to search for
* @return the element with the given string as name, or null, if any could
* be found
* @throws NullPointerException
* if the string is null
*/
public
static
SyntaxElement
getElementByName
(
final
String
s
)
{
if
(
s
==
null
)
{
throw
new
NullPointerException
(
"The string must not be null"
);
}
for
(
SyntaxElement
e
:
SyntaxElement
.
values
()
)
{
if
(
s
.
equals
(
e
.
getName
())
)
{
return
e
;
}
}
return
null
;
}
/**
* Returns the xml name of the element.
*
* @return the name
*/
public
String
getName
()
{
return
name
;
}
/**
* Returns the namespace of the element.
*
* @return the namespace
*/
public
Namespace
getNamespace
()
{
return
namespace
;
}
/**
* Returns the resource of the element.
*
* @return the resource
*/
public
static
Object
getResource
(
String
name
)
throws
AlignmentException
{
if
(
register
==
null
)
throw
new
AlignmentException
(
"Non initialized Syntax resources"
);
return
register
.
get
(
name
).
resource
;
}
/**
* Returns the namespace of the element.
*
* @return the namespace
*/
public
Constructor
getOperator
()
{
return
operator
;
}
public
static
SyntaxElement
getElement
(
Constructor
op
){
for
(
SyntaxElement
e
:
SyntaxElement
.
values
()
)
{
if
(
op
.
equals
(
e
.
getOperator
()
)
)
{
return
e
;
}
}
return
null
;
}
/**
* Formats the element to a printable string. The resulting string will
* consist of the sort form of the namespace and the name of the element
* separated by a ':' e.g. <code>rdf:resource</code>
*
* @return the formated string
*/
public
String
print
()
{
return
namespace
.
getShortCut
()
+
":"
+
name
;
}
public
String
id
()
{
return
namespace
.
getUriPrefix
()+
name
;
}
/**
* Formats the element to a printable string. Formats the string in the same
* way with the difference, that if the given namespace matches the
* namespace of the element, the formated string will not be prefixed bye
* the namespace and ':'.
*
* @param namespace
* the namespace for which not to prefix the resulting string
* @return teh formated string
* @see #print()
*/
public
String
print
(
final
Namespace
namespace
)
{
return
(
this
.
namespace
==
namespace
)
?
name
:
print
();
}
/**
* <p>
* Prints a short description of the element. The format will be the
* shortcut of the namespace, and the name of the element separated by ':'.
* </p>
* <p>
* A example string could be: <code>rdf:resource</code>
* </p>
* @return the description of the element
*/
public
String
toString
()
{
return
print
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment