Classification (Java EE 5)

Java EE API


javax.xml.registry.infomodel Interface Classification

All Superinterfaces:
ExtensibleObject, RegistryObject

public interface Classification
extends RegistryObject

Implements: RegistryObject

Classification 接口用于对 RegistryObject 实例进行分类。通过向 RegistryObject 添加 0 个或多个 Classification 实例,可以从多个角度对 RegistryObject 进行分类。例如,Organization 可以根据行业、销售的产品和地理位置进行分类。在此示例中,至少向 RegistryObject 添加了 3 个 Classification 实例。RegistryObject 接口提供了一些 addClassification 方法,使客户端能够向 RegistryObject 添加 Classification 实例。

图 1 展示了 Classification 如何使用 ClassificationScheme 对 RegistryObject 进行分类。

使用 ClassificationScheme 对对象进行分类
图 1. 使用 ClassificationScheme 对对象进行分类

内部分类和外部分类

在 JAXR 提供者中,可以使用以下方式之一表示分类:
  1. 分类元素及其彼此之间的结构关系可从 JAXR 提供者中获得。这种情况称为内部分类 (Internal Taxonomy),因为 JAXR 提供者可以从内部获得分类结构。
  2. 分类元素及其彼此之间的结构关系在 JAXR 提供者外部的某个地方表示。这种情况称为外部分类 (External Taxonomy),因为 JAXR 提供者无法从内部获得分类结构。

内部 Classification 和外部 Classification

Classification 接口允许使用 ClassificationScheme 对 RegistryObject 进行分类,不管 ClassificationScheme 表示内部分类还是外部分类。当 Classification 实例使用表示内部分类的 ClassificationScheme 时,它被称为内部 Classification。当 Classification 实例使用表示外部分类的 ClassificationScheme 时,它被称为外部 Classification。

内部 Classification

当 Classification 实例使用内部分类对 RegistryObject 进行分类时,它被称为内部 Classification。若要 Classification 使用内部分类,客户端必须对 Classification 调用 setConcept 方法,并定义对 Classification 实例中 Concept 实例的引用。客户端不必调用 setClassificationScheme 进行内部 Classification,因为分类 Concept 已知其根 ClassificationScheme。

内部 Classification 的示例

图 2 展示了一个使用 Concept 表示分类元素的内部 Classification 示例。该示例使用可用作内部分类的 NAICS 标准分类将 Organization 实例归类为 Book Publisher。注意,为了节省空间,该图没有显示 ?Book Publishers? 节点与 NAICS ClassificationScheme 之间的所有 Concept。假如显示这些 Concept,它们将通过每个 Concept 的父属性链接在一起。

内部 Classification 的示例
图 2. 内部 Classification 的示例

外部 Classification

当 Classification 实例使用外部分类对 RegistryObject 进行分类时,它被称为外部 Classification。客户端必须对 Classification 调用 setValue 方法,并定义一个唯一值,该值在理论上表示外部定义其结构的分类中的某个分类对象。客户端必须对外部 Classification 调用 setClassificationScheme,因为没有其他方式能够推断出表示外部分类的 ClassificationScheme。

外部 Classification 的示例

图 3 展示了一个外部 Classification 示例。该示例使用的场景与 Classification 使用 NAICS 标准分类将 Organization 实例归类为 Book Publisher 时使用的场景相同。但是,此时 JAXR 提供者无法从内部获得 NAICS 分类结构,并因此没有任何 Concept 实例。这时使用 Classification 的名称和值属性准确指定 Book Publisher 的分类元素。注意,名称是可选的,但值是必需的。

外部 Classification 的示例
图 3. 外部 Classification 的示例

多个 Classification 的示例

下一个示例展示了如何通过多个 Classification 方案对 RegistryObject 进行分类。在此例中,使用名为 Industry 和 Geography 的两个内部 ClassificationScheme 对几个 Organization RegistryObject 进行分类(根据其行业和地理位置)。在图 4 中,为了节省空间和提高可读性,没有明确显示 Classification 实例,而是将它隐含在 RegistryObject(阴影显示的叶节点)与相关 Concept 之间的关联中。

多个 Classification 的示例
图 4. 多个 Classification 的示例
英文文档:

The Classification interface is used to classify RegistryObject instances. A RegistryObject may be classified along multiple dimensions by adding zero or more Classification instances to the RegistryObject. For example, an Organization may be classified by its industry, by the products it sells and by its geographical location. In this example the RegistryObject would have at least three Classification instances added to it. The RegistryObject interface provides several addClassification methods to allow a client to add Classification instances to a Registry Object.

Figure 1 shows how a Classification classifies a RegistryObject using a ClassificationScheme.

Using a ClassificationScheme to Classify an Object
Figure 1. Using a ClassificationScheme to Classify an Object

Internal vs. External Taxonomies

A taxonomy may be represented within a JAXR provider in one of the following ways:
  1. The taxonomy elements and their structural relationship with each other are available within the JAXR provider. This case is referred to as Internal Taxonomy since the structure of the taxonomy is available internal to the JAXR provider.
  2. The taxonomy elements and their structural relationship with each other is represented somewhere external to the JAXR provider. This case is referred to as External Taxonomy since the structure of the taxonomy is not available to the JAXR provider.

Internal vs. External Classifications

The Classification interface allows the classification of RegistryObjects using a ClassificationScheme whether the ClassificationScheme represents an internal taxonomy or an external taxonomy. When a Classification instance uses a ClassificationScheme representing an internal taxonomy then it is referred to as an internal Classification. When a Classification instance uses a ClassificationScheme representing an external taxonomy then it is referred to as an external Classification.

Internal Classification

When a Classification instance is used to classify a RegistryObject using an internal taxonomy it is referred to as an internal Classification. A client must call the setConcept method on a Classification and define a reference to a Concept instance from the Classification instance in order for that Classification to use an internal taxonomy. It is not necessary for the client to call setClassificationScheme for internal Classifications since the classifying Concept already knows it root ClassificationScheme.

Example of Internal Classification

Figure 2 shows an example of internal classification using a Concept to represent a taxonomy element. The example classifies an Organization instance as a Book Publisher using the NAICS standard taxonomy available as an internal taxonomy. Note that the figure does not show all the Concepts between the ?Book Publishers? node and the NAICS ClassificationScheme to save space. Had they been there they would have been linked together by the parent attribute of each Concept.

Example of Internal Classification
Figure 2. Example of Internal Classification

External Classification

When a Classification instance is used to classify a RegistryObject using an external taxonomy it is referred to as an external Classification. A client must call the setValue method on a Classification and define a unique value that logically represents a taxonomy element within the taxonomy whose structure is defined externally. It is necessary for the client call setClassificationScheme for external Classifications since there is no other way to infer the ClassificationScheme that represents the external taxonomy.

Example of External Classification

Figure 3 shows an example of external classification. The example uses the same scenario where a Classification classifies an Organization instance as a Book Publisher using the NAICS standard taxonomy. However, this time the structure of the NAICS taxonomy is not available internally to the JAXR provider and consequently there is no Concept instance. Instead, the name and value attributes of the Classification are used to pinpoint the Book Publisher's taxonomy element. Note that name is optional but value is required.

Example of External Classification
Figure 3. Example of External Classification

An Example of Multiple Classifications

The next example shows how a RegistryObject may be classified by multiple classification schemes. In this example, two internal ClassificationSchemes named Industry and Geography are used to classify several Organization RegistryObjects by their industry and Geography. In Figure 4, in order to save space and improve readability, the Classification instances are not explicitly shown but are implied as associations between the RegistryObjects (shaded leaf node) and the associated Concepts.

Example of Multiple Classifications
Figure 4. Example of Multiple Classifications

Author:
Farrukh S. Najmi
See Also:
RegistryObject, Concept

Method Summary
 ClassificationScheme
 RegistryObject
 Concept
 String
 boolean
 void
 void
 void
 void
 
Methods inherited from interface javax.xml.registry.infomodel.RegistryObject
 
Methods inherited from interface javax.xml.registry.infomodel.ExtensibleObject
 

Method Detail

public Concept getConcept() throws JAXRException
获取对对象进行分类的 Concept。

功能级别:0
return 对已分类的对象进行分类的 Concept。如果这是一个外部 Classification,则返回 null
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
supplierCardinality0..*
clientCardinality0..*
associationAsClass
Classification
英文文档:

getConcept

Concept getConcept()
                   throws JAXRException
Gets the Concept that is classifying the object.

Capability Level: 0

Returns:
the Concept that is classifying the classified object. null if this is a external Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setConcept(Concept concept) throws JAXRException
设置此内部 Classification 的 Concept。

此方法不能与 setClassificationScheme 方法一起使用。

功能级别:0
concept 对已分类对象进行分类的 Concept。
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setConcept

void setConcept(Concept concept)
                throws JAXRException
Sets the concept for this internal classification.

This method should be used mutually exclusively with the setClassificationScheme method.

Capability Level: 0

Parameters:
concept - the Concept that is classifying the classified object.
Throws:
JAXRException - If the JAXR provider encounters an internal error

public ClassificationScheme getClassificationScheme() throws JAXRException
获取用来对对象进行分类的 ClassificationScheme。如果 Classification 是内部 Classification,则此方法应该返回对表示分类元素的 Concept 调用 getClassificationScheme 方法所返回的值。

功能级别:0
return 此 Classification 使用的 ClassificationScheme
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
associates <{ClassificationScheme}>
supplierCardinality0..1
label
classificationScheme
See also javax.xml.registry.infomodel.ClassificationScheme
英文文档:

getClassificationScheme

ClassificationScheme getClassificationScheme()
                                             throws JAXRException
Gets the ClassificationScheme that is used in classifying the object. If the Classification is an internal Classification then this method should return the value returned by calling the getClassificationScheme method on the Concept representing the taxonomy element.

Capability Level: 0

Returns:
the ClassificationScheme used by this Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error
See Also:
ClassificationScheme

public void setClassificationScheme(ClassificationScheme classificationScheme) throws JAXRException
设置此外部 Classification 的 ClassificationScheme。

调用此方法还必须调用 setValue 方法。此方法不能与 setConcept 方法一起使用。

功能级别:0
classificationScheme 此 Classification 使用的 ClassificationScheme
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setClassificationScheme

void setClassificationScheme(ClassificationScheme classificationScheme)
                             throws JAXRException
Sets the ClassificationScheme for this external classification.

If this method is called then you must also call setValue method. This method should be used mutually exclusively with the setConcept method.

Capability Level: 0

Parameters:
classificationScheme - the ClassificationScheme used by this Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public String getValue() throws JAXRException
获取此 Classification 的分类值。

功能级别:0
return 如果是外部 Classification,则返回分类元素的值;如果是内部 Classification,则返回表示分类元素的 Concept 的值
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

getValue

String getValue()
                throws JAXRException
Gets the taxonomy value for this Classification.

Capability Level: 0

Returns:
the value of the taxonomy element if external Classification; the value of the Concept representing the taxonomy element if internal Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setValue(String value) throws JAXRException
设置此外部 Classification 的分类值。

功能级别:0
value 此外部 Classification 使用的分类值
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setValue

void setValue(String value)
              throws JAXRException
Sets the taxonomy value for this external Classification.

Capability Level: 0

Parameters:
value - the taxonomy value used by this external Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public RegistryObject getClassifiedObject() throws JAXRException
获取将分类的 Object。

功能级别:0
return 根据此 Classification 进行分类的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

getClassifiedObject

RegistryObject getClassifiedObject()
                                   throws JAXRException
Gets the Object that is being classified.

Capability Level: 0

Returns:
the RegistryObject that is classified by this Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setClassifiedObject(RegistryObject classifiedObject) throws JAXRException
设置将分类的对象。

功能级别:0
classifiedObject 根据此 Classification 进行分类的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setClassifiedObject

void setClassifiedObject(RegistryObject classifiedObject)
                         throws JAXRException
Sets the object that is being classified.

Capability Level: 0

Parameters:
classifiedObject - the RegistryObject that is classified by this Classification
Throws:
JAXRException - If the JAXR provider encounters an internal error

public boolean isExternal() throws JAXRException
如果这是一个外部 Classification,则返回 true。

功能级别:0
return 如果这是一个外部 Classification,则返回 true;否则返回 false
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

isExternal

boolean isExternal()
                   throws JAXRException
Returns true if this is an external classification.

Capability Level: 0

Returns:
true if this is an external Classification; false otherwise
Throws:
JAXRException - If the JAXR provider encounters an internal error


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!