javax.naming 
Class CompoundNamejava.lang.Object
  |
  +--javax.naming.CompoundName
All Implemented Interfaces: 
Cloneable, Name, Serializable public class CompoundName
extends Object
implements NamegetPrefix
public Name getPrefix(int posn)Creates a compound name whose components consist of a prefix of the components in this compound name. The result and this compound name share the same syntax. Subsequent changes to this compound name does not affect the name that is returned and vice versa.
Specified by: 
getPrefix in interface Name
Parameters:
posn - The 0-based index of the component at which to stop. Must be in the range [0,size()].
Returns:
A compound name consisting of the components at indexes in the range [0,posn).
Throws:
ArrayIndexOutOfBoundsException - If posn is outside the specified range.

解决方案 »

  1.   

    新手。我想用getPrefix()得到namespace.看了http://sparta-xml.sourceforge.net/api/com/hp/hpl/thermopylae/ElementImpl.html#getPrefix()后一头雾水。不知道如何使用。我的RDF有
    <uni:HasStudentID>02908590</uni:HasStudentID>
    我想得到uni:HasStudentID,getPrefix()应该可以。如何使用?我的jena如下
    // get the predicate
    Property  property = stmt.getPredicate(); 
    System.out.println("predicate = "+property.getLocalName())谢谢