本文整理了Java中net.sf.saxon.om.Item.getGenre()
方法的一些代码示例,展示了Item.getGenre()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getGenre()
方法的具体详情如下:
包路径:net.sf.saxon.om.Item
类名称:Item
方法名:getGenre
[英]Get the genre of this item (to distinguish the top-level categories of item, such as nodes, atomic values, and functions)
[中]获取此项的类型(以区分项的顶级类别,例如节点、原子值和函数)
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
default Optional<String> explainMismatch(Item item, TypeHierarchy th) {
if (item instanceof AtomicValue) {
return Optional.of("The supplied value is of type " + ((AtomicValue) item).getItemType());
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
default Optional<String> explainMismatch(Item item, TypeHierarchy th) {
if (item instanceof AtomicValue) {
return Optional.of("The supplied value is of type " + ((AtomicValue) item).getItemType());
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
public Optional<String> explainMismatch(Item item, TypeHierarchy th) {
if (item instanceof NodeInfo) {
UType actualKind = UType.getUType(item);
if (!getUType().overlaps(actualKind)) {
return Optional.of("The supplied value is " + actualKind.toStringWithIndefiniteArticle());
}
return Optional.empty();
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
public Optional<String> explainMismatch(Item item, TypeHierarchy th) {
if (item instanceof NodeInfo) {
UType actualKind = UType.getUType(item);
if (!getUType().overlaps(actualKind)) {
return Optional.of("The supplied value is " + actualKind.toStringWithIndefiniteArticle());
}
return Optional.empty();
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
public Optional<String> explainMismatch(Item item, TypeHierarchy th) {
Optional<String> explanation = super.explainMismatch(item, th);
if (explanation.isPresent()) {
return explanation;
}
if (item instanceof NodeInfo) {
UType actualKind = UType.getUType(item);
if (!getUType().overlaps(actualKind)) {
return Optional.of("The supplied value is " + actualKind.toStringWithIndefiniteArticle());
} else {
return Optional.empty();
}
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Get extra diagnostic information about why a supplied item does not conform to this
* item type, if available. If extra information is returned, it should be in the form of a complete
* sentence, minus the closing full stop. No information should be returned for obvious cases.
*
* @param item the item that doesn't match this type
* @param th the type hierarchy cache
* @return optionally, a message explaining why the item does not match the type
*/
@Override
public Optional<String> explainMismatch(Item item, TypeHierarchy th) {
Optional<String> explanation = super.explainMismatch(item, th);
if (explanation.isPresent()) {
return explanation;
}
if (item instanceof NodeInfo) {
UType actualKind = UType.getUType(item);
if (!getUType().overlaps(actualKind)) {
return Optional.of("The supplied value is " + actualKind.toStringWithIndefiniteArticle());
} else {
return Optional.empty();
}
} else {
return Optional.of("The supplied value is " + item.getGenre().getDescription());
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Construct a full error message, displaying the item in error (suitable for use when
* a type error is reported dynamically)
*
* @param requiredItemType the item type required by the context of a particular expression
* @param item the actual item in error. Must NOT be null (unlike earlier releases).
* @return a message of the form "Required item type of A is R; supplied value has item type S"
*/
public String composeErrorMessage(ItemType requiredItemType, Item item, TypeHierarchy th) {
FastStringBuffer message = new FastStringBuffer(256);
message.append(composeRequiredMessage(requiredItemType));
message.append("; the supplied value ");
message.append(Err.depict(item));
if (requiredItemType.getGenre() != item.getGenre()) {
message.append(" is ");
message.append(item.getGenre().getDescription());
} else {
message.append(" does not match. ");
if (th != null) {
Optional<String> more = requiredItemType.explainMismatch(item, th);
more.ifPresent(message::append);
}
}
return message.toString();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Construct a full error message, displaying the item in error (suitable for use when
* a type error is reported dynamically)
*
* @param requiredItemType the item type required by the context of a particular expression
* @param item the actual item in error. Must NOT be null (unlike earlier releases).
* @return a message of the form "Required item type of A is R; supplied value has item type S"
*/
public String composeErrorMessage(ItemType requiredItemType, Item item, TypeHierarchy th) {
FastStringBuffer message = new FastStringBuffer(256);
message.append(composeRequiredMessage(requiredItemType));
message.append("; the supplied value ");
message.append(Err.depict(item));
if (requiredItemType.getGenre() != item.getGenre()) {
message.append(" is ");
message.append(item.getGenre().getDescription());
} else {
message.append(" does not match. ");
if (th != null) {
Optional<String> more = requiredItemType.explainMismatch(item, th);
more.ifPresent(message::append);
}
}
return message.toString();
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
if (item.getGenre() == ATOMIC) {
FastStringBuffer message = new FastStringBuffer(256);
message.append("The required type is a union type allowing any of ");
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
if (item.getGenre() == ATOMIC) {
FastStringBuffer message = new FastStringBuffer(256);
message.append("The required type is a union type allowing any of ");
内容来源于网络,如有侵权,请联系作者删除!