本文整理汇总了Java中org.n52.oxf.xml.NcNameResolver类的典型用法代码示例。如果您正苦于以下问题:Java NcNameResolver类的具体用法?Java NcNameResolver怎么用?Java NcNameResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NcNameResolver类属于org.n52.oxf.xml包,在下文中一共展示了NcNameResolver类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCleanNCName
import org.n52.oxf.xml.NcNameResolver; //导入依赖的package包/类
/**
* @return result[0] := newName<br /> result[1] := originaleName
*/
private String[] createCleanNCName(final Resource res) {
// implement check for NCName compliance and remove bad values
String name = res.getName();
final String origName = new String(name);
// clean rest of string using Constants.UNICODE_REPLACER
final char[] foiNameChars = name.toCharArray();
for (int i = 0; i < foiNameChars.length; i++) {
final char c = foiNameChars[i];
if (!NcNameResolver.isNCNameChar(c)) {
foiNameChars[i] = Configuration.UNICODE_REPLACER;
}
}
name = String.valueOf(foiNameChars);
// check if name is only containing "_"
final Matcher matcher = Configuration.UNICODE_ONLY_REPLACER_LEFT_PATTERN.matcher(name);
if (matcher.matches()) {
// if yes -> change to "className" + res.getUri().hashCode()
name = res.getClass().getSimpleName().toLowerCase() + res.getUri().hashCode();
}
final String[] result = { name, origName };
return result;
}
示例2: getOffering
import org.n52.oxf.xml.NcNameResolver; //导入依赖的package包/类
public Offering getOffering(final Sensor s) {
final Offering off = configuration.getOffering(s);
if (!NcNameResolver.isNCName(off.getName())) {
final String[] a = createCleanNCName(off);
off.setName(a[0]);
if (!a[0].equals(a[1])) {
LOG.debug(String.format("Offering name changed to match NCName production: '%s' to '%s'",
a[1],
a[0]));
}
}
return off;
}
示例3: addResult
import org.n52.oxf.xml.NcNameResolver; //导入依赖的package包/类
private void addResult(final SweArrayObservationParameters obsParameter) {
final DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance();
final DataArrayType xbDataArray = xbDataArrayDoc.addNewDataArray1();
// count
xbDataArray.addNewElementCount().addNewCount().setValue(BigInteger.valueOf(timeseries.size()));
// element type
final DataRecordType xbDataRecord = DataRecordType.Factory.newInstance();
// phentime
final Field xbPhenTime = xbDataRecord.addNewField();
xbPhenTime.setName("phenomenonTime");
final TimeType xbTimeWithUom = TimeType.Factory.newInstance();
xbTimeWithUom.setDefinition("http://www.opengis.net/def/property/OGC/0/PhenomenonTime");
xbTimeWithUom.addNewUom().setHref("http://www.opengis.net/def/uom/ISO-8601/0/Gregorian");
xbPhenTime.addNewAbstractDataComponent().set(xbTimeWithUom);
xbPhenTime
.getAbstractDataComponent()
.substitute(XMLConstants.QN_SWE_2_0_TIME, TimeType.type);
// obsProp
final Field xbObsProperty = xbDataRecord.addNewField();
xbObsProperty.setName(NcNameResolver.fixNcName(getObservedProperty().getName()));
final QuantityType xbQuantityWithUom = QuantityType.Factory.newInstance();
xbQuantityWithUom.setDefinition(getObservedProperty().getUri());
xbQuantityWithUom.addNewUom().setCode(getUnitOfMeasurementCode());
xbObsProperty.addNewAbstractDataComponent().set(xbQuantityWithUom);
xbObsProperty
.getAbstractDataComponent()
.substitute(XMLConstants.QN_SWE_2_0_QUANTITY, QuantityType.type);
final ElementType xbElementType = xbDataArray.addNewElementType();
xbElementType.setName("definition");
xbElementType.addNewAbstractDataComponent().set(xbDataRecord);
xbElementType
.getAbstractDataComponent()
.substitute(XMLConstants.QN_SWE_2_0_DATA_RECORD, DataRecordType.type);
// encoding
final TextEncodingType textEncoding = TextEncodingType.Factory.newInstance();
// token
textEncoding.setTokenSeparator(tokenSeparator);
// block seperator
textEncoding.setBlockSeparator(blockSeparator);
xbDataArray.addNewEncoding().addNewAbstractEncoding().set(textEncoding);
xbDataArray
.getEncoding().getAbstractEncoding()
.substitute(XMLConstants.QN_SWE_2_0_TEXT_ENCODING, TextEncodingType.type);
// values
xbDataArray.addNewValues().set(createValuesString());
obsParameter.addObservationValue(xbDataArrayDoc.xmlText());
}
示例4: unwrapSensorMLFrom
import org.n52.oxf.xml.NcNameResolver; //导入依赖的package包/类
public static SensorMLDocument unwrapSensorMLFrom(XmlObject xmlObject) throws XmlException, XMLHandlingException, IOException {
if (SoapUtil.isSoapEnvelope(xmlObject)) {
xmlObject = SoapUtil.stripSoapEnvelope(xmlObject);
}
if (xmlObject instanceof SensorMLDocument) {
return (SensorMLDocument) xmlObject;
}
if (xmlObject instanceof DescribeSensorResponseDocument) {
DescribeSensorResponseDocument responseDoc = (DescribeSensorResponseDocument) xmlObject;
DescribeSensorResponseType response = responseDoc.getDescribeSensorResponse();
DescribeSensorResponseType.Description[] descriptionArray = response.getDescriptionArray();
if (descriptionArray.length == 0) {
LOGGER.warn("No SensorDescription available in response!");
}
else {
for (DescribeSensorResponseType.Description description : descriptionArray) {
SensorDescriptionType.Data dataDescription = description.getSensorDescription().getData();
String namespace = "declare namespace gml='http://www.opengis.net/gml'; ";
for (XmlObject xml : dataDescription.selectPath(namespace + "$this//*/@gml:id")) {
XmlCursor cursor = xml.newCursor();
String gmlId = cursor.getTextValue();
if ( !NcNameResolver.isNCName(gmlId)) {
cursor.setTextValue(NcNameResolver.fixNcName(gmlId));
}
}
XmlObject object = XmlObject.Factory.parse(dataDescription.xmlText());
if (object instanceof SystemDocumentImpl) {
SensorMLDocument smlDoc = SensorMLDocument.Factory.newInstance();
SensorMLDocument.SensorML.Member member = smlDoc.addNewSensorML().addNewMember();
member.set(XMLBeansParser.parse(object.newInputStream()));
return smlDoc;
}
return SensorMLDocument.Factory.parse(dataDescription.newInputStream());
}
}
}
LOGGER.warn("Failed to unwrap SensorML from '{}'. Return an empty description.", xmlObject.xmlText());
return SensorMLDocument.Factory.newInstance();
}