public String extractString(String defaultValue) { if (xnode instanceof PrimitiveXNode) { return ((PrimitiveXNode<?>) xnode).getStringValue(); } else { return defaultValue; } }
public MapXNode getFilterClauseXNode() { if (this.filterClauseXNode == null) { return null; } else { return this.filterClauseXNode.clone(); } }
public RawType(XNode node, @NotNull PrismContext prismContext) { this(prismContext); this.xnode = node; if (this.xnode != null) { this.explicitTypeName = xnode.getTypeQName(); this.explicitTypeDeclaration = xnode.isExplicitTypeDeclaration(); } }
public static RawType create(String value, PrismContext prismContext) { PrimitiveXNode<String> xnode = prismContext.xnodeFactory().primitive(value); return new RawType(xnode, prismContext); }
public static void assertSubnode(MapXNode xmap, QName key, Class expectedClass) { XNode xsubnode = xmap.get(key); assert xsubnode != null : "No subnode "+key+" in "+xmap; assert expectedClass.isAssignableFrom(xsubnode.getClass()) : "Wrong class of subnode "+key+" in "+xmap+"; expected "+expectedClass+", got "+xsubnode.getClass(); }
public static void displaySearchFilterType(SearchFilterType filterType) throws SchemaException { MapXNode mapXNode = filterType.getFilterClauseXNode(); String dumpX = mapXNode.debugDump(); LOGGER.info(dumpX); System.out.println("filter clause xnode:\n" + dumpX + "\n"); String dumpXml = prismContext.xmlSerializer().serialize( prismContext.xnodeFactory().root(new QName("filterClauseXNode"), mapXNode)); System.out.println("filter clause xnode serialized:\n" + dumpXml + "\n"); }
private MapXNodeImpl toMap(XNode xnode) throws SchemaException { if (xnode instanceof PrimitiveXNodeImpl && xnode.isEmpty()) { return new MapXNodeImpl(); // hack but it might work (todo implement better) } else if (!(xnode instanceof MapXNodeImpl)) { throw new SchemaException("Cannot parse filter from "+xnode); } else { return (MapXNodeImpl) xnode; } }
public void setFilterClauseXNode(RootXNode filterClauseNode) { if (filterClauseNode == null) { this.filterClauseXNode = null; } else { this.filterClauseXNode = filterClauseNode.toMapXNode(); } }
@NotNull public RootXNode getRootXNode(@NotNull QName itemName) { return prismContext.xnodeFactory().root(itemName, xnode); }
public boolean containsFilterClause() { return filterClauseXNode != null && !filterClauseXNode.isEmpty(); }
private void parseValue(@NotNull QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException { Validate.notNull(typeName, "Cannot parse primitive XNode without knowing its type"); if (valueParser != null) { value = valueParser.parse(typeName, mode); // Necessary. It marks that the value is parsed. It also frees some memory. valueParser = null; } }
public RootXNode getFilterClauseAsRootXNode() throws SchemaException { MapXNode clause = getFilterClauseXNode(); return clause != null ? clause.getSingleSubEntryAsRoot("getFilterClauseAsRootXNode") : null; }
public static void assertSize(ListXNode xlist, int expectedSize) { assertEquals("Wrong size of "+xlist, expectedSize, xlist.size()); }
public static void assertSize(MapXNode xmap, int expectedSize) { assertEquals("Wrong size of "+xmap, expectedSize, xmap.size()); }
public String guessFormattedValue() throws SchemaException { if (parsed != null) { return parsed.getRealValue().toString(); // todo reconsider this } else if (xnode instanceof PrimitiveXNode) { return ((PrimitiveXNode) xnode).getGuessedFormattedValue(); } else { return null; } } }
public boolean isEmpty() { if (!isParsed()) { return valueParser.isEmpty(); } if (value == null) { return true; } if (value instanceof String) { return StringUtils.isBlank((String)value); } return false; }
public RawType clone() { RawType clone = new RawType(prismContext); if (xnode != null) { clone.xnode = xnode.clone(); } else if (parsed != null) { clone.parsed = parsed.clone(); } clone.explicitTypeName = explicitTypeName; clone.explicitTypeDeclaration = explicitTypeDeclaration; return clone; }
/** * TEMPORARY. EXPERIMENTAL. DO NOT USE. */ public String extractString() { if (xnode instanceof PrimitiveXNode) { return ((PrimitiveXNode<?>) xnode).getStringValue(); } else { return toString(); } }
/** * Creates a new {@code QueryType} instance by deeply copying a given {@code QueryType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public SearchFilterType(final SearchFilterType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'SearchFilterType' from 'null'."); } this.filterClauseXNode = o.filterClauseXNode.clone(); }