private void preCalculateElementsForProperty(Element tree) { elementsForProperty = new ArrayList<>(); Element element = tree != null ? tree.element( "attributes" ) : null; //put entity.attributes elements if ( element != null ) { for ( Element subelement : (List<Element>) element.elements() ) { if ( propertyName.equals( subelement.attributeValue( "name" ) ) ) { elementsForProperty.add( subelement ); } } } //add pre-* etc from entity and pure entity listener classes if ( tree != null ) { for ( Element subelement : (List<Element>) tree.elements() ) { if ( propertyName.equals( subelement.attributeValue( "method-name" ) ) ) { elementsForProperty.add( subelement ); } } } }
private static List<String> getNames( String type, Document webXml ) { final List<String> result = new ArrayList<>(); final List<Element> elements = webXml.getRootElement().elements( type ); // all elements of 'type' (filter or servlet). for ( final Element element : elements ) { final String name = element.elementTextTrim( type + "-name" ); if ( name != null && !name.isEmpty() ) { result.add( name ); } } return result; }
private List<String> getChildPropertyNamesFor(Element parent, String parentName) { List<String> result = new ArrayList<>(); for (Element child : parent.elements()) { String childName = parentName + (parentName.isEmpty() ? "" : ".") + child.getName(); if (!result.contains(childName)) { result.add(childName); result.addAll(getChildPropertyNamesFor(child, childName)); } } return result; }
private Columns buildColumns(Element element) { List<Element> subelements = element.elements( "column" ); List<Column> columns = new ArrayList<>( subelements.size() ); for ( Element subelement : subelements ) { columns.add( getColumn( subelement, false, element ) ); } if ( columns.size() > 0 ) { AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class ); columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) ); return AnnotationFactory.create( columnsDescr ); } else { return null; } }
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) { if ( element == null ) { return new PrimaryKeyJoinColumn[] { }; } List pkJoinColumnElementList = element.elements( "primary-key-join-column" ); PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()]; int index = 0; Iterator pkIt = pkJoinColumnElementList.listIterator(); while ( pkIt.hasNext() ) { Element subelement = (Element) pkIt.next(); AnnotationDescriptor pkAnn = new AnnotationDescriptor( PrimaryKeyJoinColumn.class ); copyStringAttribute( pkAnn, subelement, "name", false ); copyStringAttribute( pkAnn, subelement, "referenced-column-name", false ); copyStringAttribute( pkAnn, subelement, "column-definition", false ); pkJoinColumns[index++] = AnnotationFactory.create( pkAnn ); } return pkJoinColumns; }
private List<Element> getIncrementActivityNodes(String packageName, List<Element> newActivityNodes, Collection<String> incActivities) { final List<Element> result = new ArrayList<>(); for (Element newActivityNode : newActivityNodes) { String activityClazzName = newActivityNode.attributeValue(XML_NODEATTR_NAME); if (activityClazzName.charAt(0) == '.') { activityClazzName = packageName + activityClazzName; } if (!incActivities.contains(activityClazzName)) { continue; } final String exportedVal = newActivityNode.attributeValue(XML_NODEATTR_EXPORTED, Utils.isNullOrNil(newActivityNode.elements(XML_NODENAME_INTENTFILTER)) ? "false" : "true"); if ("true".equalsIgnoreCase(exportedVal)) { announceWarningOrException( String.format("found a new exported activity %s" + ", tinker does not support increase exported activity.", activityClazzName) ); } final String processVal = newActivityNode.attributeValue(XML_NODEATTR_PROCESS); if (processVal != null && processVal.charAt(0) == ':') { announceWarningOrException( String.format("found a new activity %s which would be run in standalone process" + ", tinker does not support increase such kind of activities.", activityClazzName) ); } Logger.d("Found increment activity: " + activityClazzName); result.add(newActivityNode); } return result; }
pageID = subPage.getParent().getParent().attributeValue("id"); if (AdminConsole.getModel().elements().size() > 0) { JspWriter out = pageContext.getOut(); StringBuilder buf = new StringBuilder(); Collection items = currentTab.elements(); if (items.size() > 0) { buf.append("<ul>"); for (Object itemObj : items) { Element item = (Element) itemObj; if (item.elements().size() > 0) { Element firstSubItem = (Element)item.elements().get(0); String pluginName = item.attributeValue("plugin"); String subitemID = item.attributeValue("id"); String subitemName = item.attributeValue("name"); String subitemURL = firstSubItem.attributeValue("url");
if (NAMESPACE.equals(((Element)it.next()).attributeValue("var"))) { supports = true; break; Collection<Element> items = packet.getChildElement().elements("item"); String jid = item.attributeValue("jid"); jids.add(jid); iq.setTo(item.attributeValue("jid")); Element child = iq.setChildElement("query", "http://jabber.org/protocol/disco#info"); if (item.attributeValue("node") != null) {
pageID = subPage.getParent().getParent().attributeValue("id"); if (AdminConsole.getModel().elements().size() > 0) { JspWriter out = pageContext.getOut(); StringBuilder buf = new StringBuilder(); Element sidebar = subnav.getParent().getParent(); String pluginName = sidebar.attributeValue("plugin"); hcss = ""; Collection items = subnav.elements(); if (items.size() > 0) { buf.append("<ul>"); String subitemID = item.attributeValue("id"); String subitemName = item.attributeValue("name"); String subitemURL = item.attributeValue("url");
Element currentRegistration = probeResult.createCopy(); currentRegistration.addElement("registered"); currentRegistration.element("username").setText(user.getUsername()); currentRegistration.element("password").setText(""); currentRegistration.element("email") .setText(user.getEmail() == null ? "" : user.getEmail()); currentRegistration.element("name").setText(user.getName()); while (fields.hasNext()) { field = (Element) fields.next(); if ("username".equals(field.attributeValue("var"))) { field.addElement("value").addText(user.getUsername()); else if ("name".equals(field.attributeValue("var"))) { field.addElement("value").addText(user.getName()); else if ("email".equals(field.attributeValue("var"))) { field.addElement("value") .addText(user.getEmail() == null ? "" : user.getEmail()); if (iqElement.elements().size() == 2 && iqElement.element("username") != null && iqElement.element("password") != null) {
final Element listElement = defaultPrivacyList.asElement(); final Set<Element> toRemove = new HashSet<>(); for ( final Element element : listElement.elements( "item" ) ) final JID jid = new JID( element.attributeValue( "value" ) ); if ( "jid".equals( element.attributeValue( "type" ) ) && "deny".equals( element.attributeValue( "action" ) ) && toUnblocks.contains( jid ) )
return; //a primitive type most likely Element element = tree != null ? tree.element( "attributes" ) : null; for ( Element subelement : (List<Element>) element.elements() ) { String propertyName = subelement.attributeValue( "name" ); if ( !properties.contains( propertyName ) ) { LOG.propertyNotFound( StringHelper.qualify( className, propertyName ) );
public Reflections read(InputStream inputStream) { Reflections reflections; try { Constructor<Reflections> constructor = Reflections.class.getDeclaredConstructor(); constructor.setAccessible(true); reflections = constructor.newInstance(); } catch (Exception e) { reflections = new Reflections(new ConfigurationBuilder()); } try { Document document = new SAXReader().read(inputStream); for (Object e1 : document.getRootElement().elements()) { Element index = (Element) e1; for (Object e2 : index.elements()) { Element entry = (Element) e2; Element key = entry.element("key"); Element values = entry.element("values"); for (Object o3 : values.elements()) { Element value = (Element) o3; reflections.getStore().getOrCreate(index.getName()).put(key.getText(), value.getText()); } } } } catch (DocumentException e) { throw new ReflectionsException("could not read.", e); } catch (Throwable e) { throw new RuntimeException("Could not read. Make sure relevant dependencies exist on classpath.", e); } return reflections; }
"x", "http://jabber.org/protocol/muc#user"); if (userInfo != null && userInfo.element("decline") != null) { Element info = userInfo.element("decline"); server.getChatRoom(group).sendInvitationRejection( new JID(info.attributeValue("to")), info.elementTextTrim("reason"), packet.getFrom()); if (userInfo != null && userInfo.element("invite") != null) { .getElement().elements()); extensions.remove(userInfo); while(it.hasNext()) { Element info = it.next(); JID jid = new JID(info.attributeValue("to")); Element info = userInfo.element("decline"); room.sendInvitationRejection(new JID(info.attributeValue("to")), info.elementTextTrim("reason"), packet.getFrom());
private void getCascades(AnnotationDescriptor ad, Element element, XMLContext.Default defaults) { List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<>( 0 ); List<CascadeType> cascades = new ArrayList<>(); for ( Element subelement : elements ) { if ( subelement.element( "cascade-all" ) != null ) { cascades.add( CascadeType.ALL ); if ( subelement.element( "cascade-persist" ) != null ) { cascades.add( CascadeType.PERSIST ); if ( subelement.element( "cascade-merge" ) != null ) { cascades.add( CascadeType.MERGE ); if ( subelement.element( "cascade-remove" ) != null ) { cascades.add( CascadeType.PERSIST ); if ( cascades.size() > 0 ) { ad.setValue( "cascade", cascades.toArray( new CascadeType[cascades.size()] ) );
private static void bindNamedAttributeNodes(Element subElement, AnnotationDescriptor ann) { List<Element> namedAttributeNodes = subElement.elements("named-attribute-node"); List<NamedAttributeNode> annNamedAttributeNodes = new ArrayList<>( ); for(Element namedAttributeNode : namedAttributeNodes){ AnnotationDescriptor annNamedAttributeNode = new AnnotationDescriptor( NamedAttributeNode.class ); copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "value", "name", true ); copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "subgraph", false ); copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "key-subgraph", false ); annNamedAttributeNodes.add( AnnotationFactory.create( annNamedAttributeNode ) ); } ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[annNamedAttributeNodes.size()] ) ); }
private static void buildIndex(AnnotationDescriptor annotation, Element element){ List indexElementList = element.elements( "index" ); Index[] indexes = new Index[indexElementList.size()]; for(int i=0;i<indexElementList.size();i++){ Element subelement = (Element)indexElementList.get( i ); AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class ); copyStringAttribute( indexAnn, subelement, "name", false ); copyStringAttribute( indexAnn, subelement, "column-list", true ); copyBooleanAttribute( indexAnn, subelement, "unique" ); indexes[i] = AnnotationFactory.create( indexAnn ); } annotation.setValue( "indexes", indexes ); } private static void buildUniqueConstraints(AnnotationDescriptor annotation, Element element) {