本文整理汇总了Java中com.espertech.esper.event.property.PropertyParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyParser.parse方法的具体用法?Java PropertyParser.parse怎么用?Java PropertyParser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.espertech.esper.event.property.PropertyParser
的用法示例。
在下文中一共展示了PropertyParser.parse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWriter
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
public MapEventBeanPropertyWriter getWriter(String propertyName)
{
if (writablePropertyDescriptors == null)
{
initializeWriters();
}
Pair<EventPropertyDescriptor, MapEventBeanPropertyWriter> pair = propertyWriters.get(propertyName);
if (pair != null) {
return pair.getSecond();
}
Property property = PropertyParser.parse(propertyName, false);
if (property instanceof MappedProperty) {
MappedProperty mapProp = (MappedProperty) property;
return new MapEventBeanPropertyWriterMapProp(mapProp.getPropertyNameAtomic(), mapProp.getKey());
}
if (property instanceof IndexedProperty) {
IndexedProperty indexedProp = (IndexedProperty) property;
return new MapEventBeanPropertyWriterIndexedProp(indexedProp.getPropertyNameAtomic(), indexedProp.getIndex());
}
return null;
}
示例2: getIndexedAndMappedProps
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
public static MapIndexedPropPair getIndexedAndMappedProps(String[] properties) {
Set<String> mapPropertiesToCopy = new HashSet<String>();
Set<String> arrayPropertiesToCopy = new HashSet<String>();
for (int i = 0; i < properties.length; i++) {
Property prop = PropertyParser.parse(properties[i], false);
if (prop instanceof MappedProperty) {
MappedProperty mappedProperty = (MappedProperty) prop;
mapPropertiesToCopy.add(mappedProperty.getPropertyNameAtomic());
}
if (prop instanceof IndexedProperty) {
IndexedProperty indexedProperty = (IndexedProperty) prop;
arrayPropertiesToCopy.add(indexedProperty.getPropertyNameAtomic());
}
}
return new MapIndexedPropPair(mapPropertiesToCopy, arrayPropertiesToCopy);
}
示例3: getStreamIndex
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
private static Pair<Integer, String> getStreamIndex(String resolvedPropertyName)
{
Property property = PropertyParser.parse(resolvedPropertyName, false);
if (!(property instanceof NestedProperty))
{
throw new IllegalStateException("Expected a nested property providing an index for array match '" + resolvedPropertyName + "'");
}
NestedProperty nested = ((NestedProperty) property);
if (nested.getProperties().size() < 2)
{
throw new IllegalStateException("Expected a nested property name for array match '" + resolvedPropertyName + "', none found");
}
if (!(nested.getProperties().get(0) instanceof IndexedProperty))
{
throw new IllegalStateException("Expected an indexed property for array match '" + resolvedPropertyName + "', please provide an index");
}
int index = ((IndexedProperty) nested.getProperties().get(0)).getIndex();
nested.getProperties().remove(0);
StringWriter writer = new StringWriter();
nested.toPropertyEPL(writer);
return new Pair<Integer, String>(index, writer.toString());
}
示例4: doResolvePropertyType
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
protected Class doResolvePropertyType(String propertyExpression) {
EsperEPL2GrammarParser.StartEventPropertyRuleContext ast = PropertyParser.parse(propertyExpression);
if (PropertyParser.isPropertyDynamic(ast)) {
return org.w3c.dom.Node.class;
} else {
return String.class;
}
}
示例5: doResolvePropertyType
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
protected Class doResolvePropertyType(String propertyExpression) {
Tree ast = PropertyParser.parse(propertyExpression);
if (PropertyParser.isPropertyDynamic(ast))
{
return org.w3c.dom.Node.class;
}
else
{
return String.class;
}
}
示例6: doResolvePropertyType
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
private Class doResolvePropertyType(String propertyExpression, boolean allowSimpleProperties) {
// see if this is an indexed property
int index = ASTFilterSpecHelper.unescapedIndexOfDot(propertyExpression);
if ((!allowSimpleProperties) && (index == -1))
{
// parse, can be an indexed property
Property property = PropertyParser.parse(propertyExpression, false);
if (!property.isDynamic())
{
if (!(property instanceof IndexedProperty))
{
return null;
}
IndexedProperty indexedProp = (IndexedProperty) property;
EventPropertyDescriptor descriptor = propertyDescriptorMap.get(indexedProp.getPropertyNameAtomic());
if (descriptor == null)
{
return null;
}
return descriptor.getPropertyType();
}
}
Property prop = PropertyParser.parse(propertyExpression, false);
if (prop.isDynamic())
{
return Node.class;
}
SchemaItem item = prop.getPropertyTypeSchema(schemaModelRoot, this.getEventAdapterService());
if (item == null)
{
return null;
}
return SchemaUtil.toReturnType(item);
}
示例7: resolveDynamicProperty
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
private TypedEventPropertyGetter resolveDynamicProperty(String property) throws XPathExpressionException {
// not defined, come up with an XPath
EsperEPL2GrammarParser.StartEventPropertyRuleContext ast = PropertyParser.parse(property);
String xPathExpr = SimpleXMLPropertyParser.walk(ast, property, config.getRootElementName(), defaultNamespacePrefix, config.isResolvePropertiesAbsolute());
return resolvePropertyGetter(property, xPathExpr, XPathConstants.STRING, null);
}
示例8: doResolveFragmentType
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
protected FragmentEventType doResolveFragmentType(String property)
{
if ((!this.getConfigurationEventTypeXMLDOM().isAutoFragment()) || (this.getConfigurationEventTypeXMLDOM().isXPathPropertyExpr()))
{
return null;
}
Property prop = PropertyParser.parse(property, false);
SchemaItem item = prop.getPropertyTypeSchema(schemaModelRoot, this.getEventAdapterService());
if ((item == null) || (!canFragment(item)))
{
return null;
}
SchemaElementComplex complex = (SchemaElementComplex) item;
// build name of event type
String[] atomicProps = prop.toPropertyArray();
String delimiterDot = ".";
StringBuilder eventTypeNameBuilder = new StringBuilder(this.getName());
for (String atomic : atomicProps)
{
eventTypeNameBuilder.append(delimiterDot);
eventTypeNameBuilder.append(atomic);
}
String eventTypeName = eventTypeNameBuilder.toString();
// check if the type exists, use the existing type if found
EventType existingType = this.getEventAdapterService().getExistsTypeByName(eventTypeName);
if (existingType != null)
{
return new FragmentEventType(existingType, complex.isArray(), false);
}
// add a new type
ConfigurationEventTypeXMLDOM xmlDom = new ConfigurationEventTypeXMLDOM();
xmlDom.setRootElementName("//" + complex.getName()); // such the reload of the type can resolve it
xmlDom.setRootElementNamespace(complex.getNamespace());
xmlDom.setAutoFragment(this.getConfigurationEventTypeXMLDOM().isAutoFragment());
xmlDom.setEventSenderValidatesRoot(this.getConfigurationEventTypeXMLDOM().isEventSenderValidatesRoot());
xmlDom.setXPathPropertyExpr(this.getConfigurationEventTypeXMLDOM().isXPathPropertyExpr());
xmlDom.setXPathResolvePropertiesAbsolute(this.getConfigurationEventTypeXMLDOM().isXPathResolvePropertiesAbsolute());
xmlDom.setSchemaResource(this.getConfigurationEventTypeXMLDOM().getSchemaResource());
xmlDom.setSchemaText(this.getConfigurationEventTypeXMLDOM().getSchemaText());
xmlDom.setXPathFunctionResolver(this.getConfigurationEventTypeXMLDOM().getXPathFunctionResolver());
xmlDom.setXPathVariableResolver(this.getConfigurationEventTypeXMLDOM().getXPathVariableResolver());
xmlDom.setDefaultNamespace(this.getConfigurationEventTypeXMLDOM().getDefaultNamespace());
xmlDom.addNamespacePrefixes(this.getConfigurationEventTypeXMLDOM().getNamespacePrefixes());
EventType newType;
try
{
newType = this.getEventAdapterService().addXMLDOMType(eventTypeName, xmlDom, schemaModel, true);
}
catch (Exception ex)
{
log.error("Failed to add dynamic event type for fragment of XML schema for property '" + property + "' :" + ex.getMessage(), ex);
return null;
}
return new FragmentEventType(newType, complex.isArray(), false);
}
示例9: coerceProperty
import com.espertech.esper.event.property.PropertyParser; //导入方法依赖的package包/类
private static Object coerceProperty(String propertyName, Class containingType, Object value, Class type, EngineImportService engineImportService, boolean forceNumeric) throws ExprValidationException {
if (value instanceof ExprNode && type != ExprNode.class) {
if (value instanceof ExprIdentNode) {
ExprIdentNode identNode = (ExprIdentNode) value;
Property prop;
try {
prop = PropertyParser.parse(identNode.getFullUnresolvedName(), false);
}
catch (Exception ex) {
throw new ExprValidationException("Failed to parse property '" + identNode.getFullUnresolvedName() + "'");
}
if (!(prop instanceof MappedProperty)) {
throw new ExprValidationException("Unrecognized property '" + identNode.getFullUnresolvedName() + "'");
}
MappedProperty mappedProperty = (MappedProperty) prop;
if (mappedProperty.getPropertyNameAtomic().toLowerCase().equals(SYSTEM_PROPETIES_NAME)) {
return System.getProperty(mappedProperty.getKey());
}
}
else {
ExprNode exprNode = (ExprNode) value;
ExprEvaluator evaluator = exprNode.getExprEvaluator();
if (evaluator == null) {
throw new ExprValidationException("Failed to evaluate expression '" + exprNode.toExpressionString() + "'");
}
value = evaluator.evaluate(null, true, null);
}
}
if (value == null) {
return null;
}
if (value.getClass() == type) {
return value;
}
if (JavaClassHelper.isAssignmentCompatible(value.getClass(), type)) {
if (forceNumeric && JavaClassHelper.getBoxedType(value.getClass()) != JavaClassHelper.getBoxedType(type) && JavaClassHelper.isNumeric(type) && JavaClassHelper.isNumeric(value.getClass())) {
value = JavaClassHelper.coerceBoxed((Number) value, JavaClassHelper.getBoxedType(type));
}
return value;
}
if (JavaClassHelper.isSubclassOrImplementsInterface(value.getClass(), type)) {
return value;
}
if (type.isArray()) {
if (!(value instanceof Collection)) {
throw new ExprValidationException("Property '" + propertyName + "' of class " + JavaClassHelper.getClassNameFullyQualPretty(containingType) + " expects an array but receives a value of type " + value.getClass().getName());
}
Object[] items = ((Collection) value).toArray();
Object coercedArray = Array.newInstance(type.getComponentType(), items.length);
for (int i = 0; i < items.length; i++) {
Object coercedValue = coerceProperty(propertyName + " (array element)", type, items[i], type.getComponentType(), engineImportService, false);
Array.set(coercedArray, i, coercedValue);
}
return coercedArray;
}
if (!(value instanceof Map)) {
throw new ExprValidationException("Property '" + propertyName + "' of class " + JavaClassHelper.getClassNameFullyQualPretty(containingType) + " expects an " + JavaClassHelper.getClassNameFullyQualPretty(type) + " but receives a value of type " + value.getClass().getName());
}
Map<String, Object> props = (Map<String, Object>) value;
return instantiatePopulateObject(props, type, engineImportService);
}