@SuppressWarnings({"unchecked", "resource"}) private ElementScript getClassName(Node node, String normailzator) { String value = XMLUtil.getTextContent(node, ".", true); ValueSourceType qsSourceType = ValueSourceType.valueOf(XMLUtil.getTextContent(node, "@source", true, "STATIC", true)); try { if (qsSourceType == ValueSourceType.GROOVY_FILE || qsSourceType == ValueSourceType.FILE || qsSourceType == ValueSourceType.JAVA_CLASS) { return new ElementScript(qsSourceType, value); } else { AppEnv.logger.errorLogEntry( "Included script did not implemented, form rule=" + parentRule.getID() + ", node=" + node.getBaseURI()); } } catch (MultipleCompilationErrorsException e) { AppEnv.logger.errorLogEntry( "Script compilation error at form rule compiling=" + parentRule.getID() + ", node=" + node.getBaseURI()); AppEnv.logger.errorLogEntry(e.getMessage()); } return null; }
// Insert an element into the queue according to its priority void put(IElement x) { if (len == SIZE) { System.out.println("can't add an element because the boat is full - Data:" + x.toString()); return; } if (len == 0) { q[0] = x; len++; return; } boolean done = false; for (int i = 0; i < len; i++) { if (q[i].getPriority() >= x.getPriority()) { // moving all higher priorities one up to make space for the new element (could be better // solved using dynamic list, but w/e) for (int ii = len; ii != (i - 1); ii--) { q[ii + 1] = q[ii]; } // since whe have space now, we can insert the new element q[i] = x; done = true; break; } } if (!done) q[len] = x; // as we added an element, we gotta increment the length len++; }
/** * @param element abstract syntax tree element * @return how the abstract syntax tree element relates to the scope to which it belongs */ public static ScopeMembership membership(final IElement element) { if (element instanceof IGenericParameter) return ScopeMembership.GenericParameter; else if (element instanceof INamedElement) { if (element.parent() == null) return ScopeMembership.Root; else if (element.parent() instanceof INamedElementContainer) { if (((INamedElement) element).hasAttribute(INamedElement.Attribute.Constructor)) return ScopeMembership.ConstructorMember; else if (element.parent() instanceof INamespace || ((INamedElement) element).hasAttribute(INamedElement.Attribute.Static)) return ScopeMembership.StaticMember; else return ScopeMembership.InstanceMember; } else return ScopeMembership.Local; } else return ScopeMembership.Local; }
public static String getValue(final IElement node, final String text) { String newText = new String(""); // $NON-NLS-1$ if (text == null) { return newText; } IElementParameter param = null; boolean end = false; List<IElementParameter> params = (List<IElementParameter>) node.getElementParametersWithChildrens(); if (params != null && !params.isEmpty()) { for (int i = 0; i < params.size() && !end; i++) { param = params.get(i); if (text.indexOf(param.getVariableName()) != -1) { newText = getDisplayValue(param); end = true; } } } // see feature 3725 replace tMsgBox MESSAGE parameter if (node instanceof INode) { INode valueNode = (INode) node; /* * Apply to all components in Perl mode */ if (isPerlProject()) { return PerlVarParserUtils.findAndReplacesAll(newText, valueNode); } } return newText; }
public static String parse(final IElement element, final String text) { String newText = ""; // $NON-NLS-1$ if ((element == null) || (text == null)) { return newText; } IElementParameter param; newText = text; for (int i = 0; i < element.getElementParameters().size(); i++) { param = element.getElementParameters().get(i); if (newText.contains(param.getVariableName())) { String value = getDisplayValue(param); newText = newText.replace(param.getVariableName(), value); } } return newText; }
/** * Only work with one element. * * @param element * @param text * @return */ public static Object getObjectValueXML(final IElement element, final String text) { if (text == null) { return null; } IElementParameter param; for (int i = 0; i < element.getElementParameters().size(); i++) { param = element.getElementParameters().get(i); if (text.indexOf(param.getVariableName()) != -1) { if (param.getFieldType() == EParameterFieldType.TABLE) { return createTableValuesXML((List<Map<String, Object>>) param.getValue(), param); } return param.getValue(); } } return null; }
@Override public boolean add(IElement element) { BaseGstElement elem = (BaseGstElement) element; synchronized (elem.ownershipLock()) { elem.takeOwnership(); if (!gst_bin_add(ptr, element.getPointer())) { elem.releaseOwnership(); return false; } } return true; }
@Override public void visitSources(IElementVisitor visitor) { if (visitor == null) return; Pointer pIterator = gst_bin_iterate_sources(ptr); if (pIterator == null || pIterator == Pointer.NULL) return; boolean done = false; PointerByReference ref = new PointerByReference(); while (!done) { // This will increase the ref counter -- so we need to create an object // that doesn't increase the ref counter when it's built so on dispose(), // the ref count will be zero. switch (IteratorResult.fromNative(gst_iterator_next(pIterator, ref))) { case OK: // Passing true here tells it to increase the ref count // when building a new element from the pointer. IElement element = Element.from(ref.getValue(), true); boolean ret = visitor.visit(this, element); element.unref(); done = !ret; break; case Resync: gst_iterator_resync(pIterator); break; case Error: case Done: case Unknown: done = true; break; default: done = true; break; } } gst_iterator_free(pIterator); }
/** * Only work with one element. * * @param element * @param text * @return */ public static Object getObjectValue(final IElement element, final String text) { if (text == null) { return null; } IElementParameter param; List<IElementParameter> params = (List<IElementParameter>) element.getElementParametersWithChildrens(); if (params != null && !params.isEmpty()) { for (int i = 0; i < params.size(); i++) { param = params.get(i); if (text.indexOf(param.getVariableName()) != -1 || (param.getVariableName() != null && param.getVariableName().contains(text))) { if (param.getFieldType() == EParameterFieldType.TABLE) { return createTableValues((List<Map<String, Object>>) param.getValue(), param); } return param.getValue(); } } } return null; }
public void visit(IElement element) { element.execute(); }
public void add(IElement element) { children.add(element); if (getHeight() < element.getHeight()) { setHeight(element.getHeight()); } }
@Override public boolean remove(IElement element) { return gst_bin_remove(ptr, element.getPointer()); }