List of usage examples for org.jdom2 Element getAttributeValue
public String getAttributeValue(final String attname)
This returns the attribute value for the attribute with the given name and within no namespace, null if there is no such attribute, and the empty string if the attribute value is empty.
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private PublicSynonym getPublicSynonym(Table table, Element element) { return new PublicSynonym(element.getAttributeValue("name"), table); }
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private Grant getGrant(Table table, Element element) { return new Grant(element.getAttributeValue("name"), Boolean.parseBoolean(element.getAttributeValue("insertPriv")), Boolean.parseBoolean(element.getAttributeValue("selectPriv")), Boolean.parseBoolean(element.getAttributeValue("deletePriv")), Boolean.parseBoolean(element.getAttributeValue("updatePriv")), Boolean.parseBoolean(element.getAttributeValue("referencesPriv")), Boolean.parseBoolean(element.getAttributeValue("alterPriv")), Boolean.parseBoolean(element.getAttributeValue("indexPriv")), table); }
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private Constraint getConstraint(Table table, Element element) { Constraint constraint = new Constraint(element.getAttributeValue("name"), element.getAttributeValue("constraintType"), element.getAttributeValue("searchCondition"), element.getAttributeValue("refUserName"), element.getAttributeValue("refConstraintName"), element.getAttributeValue("deleteRule"), element.getAttributeValue("status"), element.getAttributeValue("deferrable"), element.getAttributeValue("deferred"), element.getAttributeValue("validated"), element.getAttributeValue("generated"), table); Hashtable<String, IndexColumn> container = new Hashtable<>(); List<Element> children = getChildren(element, "columns"); for (Element child : children) { IndexColumn indexColumn = new IndexColumn(child.getAttributeValue("name"), Integer.parseInt(child.getAttributeValue("position"))); container.put(indexColumn.getName(), indexColumn); }//from w ww . ja va 2s . c om constraint.getColumns().addAll(container.values()); return constraint; }
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private Index getIndex(Table table, Element element) { Index index = new Index(element.getAttributeValue("owner"), element.getAttributeValue("name"), element.getAttributeValue("tablespace"), element.getAttributeValue("type"), Boolean.parseBoolean(element.getAttributeValue("isUnique")), element.getAttributeValue("compression"), table); Hashtable<String, IndexColumn> container = new Hashtable<>(); List<Element> children = getChildren(element, "columns"); for (Element child : children) { IndexColumn indexColumn = new IndexColumn(child.getAttributeValue("name"), Integer.parseInt(child.getAttributeValue("position"))); container.put(indexColumn.getName(), indexColumn); }//from w w w. j a va 2 s. co m index.getColumns().addAll(container.values()); return index; }
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private Column getColumn(Table table, Element element) { Column column = new Column(element.getAttributeValue("name"), Integer.parseInt(element.getAttributeValue("id")), element.getAttributeValue("type"), Integer.parseInt(element.getAttributeValue("length")), Integer.parseInt(element.getAttributeValue("precision")), Integer.parseInt(element.getAttributeValue("scale")), Boolean.parseBoolean(element.getAttributeValue("nullable")), element.getAttributeValue("comments"), element.getAttributeValue("defaultValue")); column.setParent(table);//ww w . j a v a 2 s . co m return column; }
From source file:com.kixeye.kixmpp.handler.KixmppEventEngine.java
License:Apache License
/** * Publishes a stanza.//from w w w . j av a 2s. c o m * * @param channel * @param stanza */ public void publishStanza(Channel channel, Element stanza) { String to = stanza.getAttributeValue("to"); DispatchQueue queue; try { if (to != null) { queue = queues.get("address:" + to); } else { queue = queues.get("channel:" + channel.hashCode()); } } catch (ExecutionException e) { throw new RuntimeException(e); } if (to != null) { Set<KixmppStanzaHandler> recipientHandlers = stanzaHandlers .get(Tuple.from(stanza.getQualifiedName(), KixmppJid.fromRawJid(to))); if (recipientHandlers != null) { for (KixmppStanzaHandler handler : recipientHandlers) { queue.execute(new ExecuteStanzaHandler(handler, channel, stanza)); } } recipientHandlers = stanzaHandlers.get(Tuple.from(HANDLER_WILDCARD, KixmppJid.fromRawJid(to))); if (recipientHandlers != null) { for (KixmppStanzaHandler handler : recipientHandlers) { queue.execute(new ExecuteStanzaHandler(handler, channel, stanza)); } } } Set<KixmppStanzaHandler> globalHandlers = stanzaHandlers.get(Tuple.from(stanza.getQualifiedName())); if (globalHandlers != null) { for (KixmppStanzaHandler handler : globalHandlers) { queue.execute(new ExecuteStanzaHandler(handler, channel, stanza)); } } globalHandlers = stanzaHandlers.get(Tuple.from(HANDLER_WILDCARD)); if (globalHandlers != null) { for (KixmppStanzaHandler handler : globalHandlers) { queue.execute(new ExecuteStanzaHandler(handler, channel, stanza)); } } }
From source file:com.kixeye.kixmpp.KixmppStreamStart.java
License:Apache License
/** * Creates a stream start.// w ww . j av a2 s.c o m * * @param element */ public KixmppStreamStart(Element element, boolean includeXmlHeader) { this.includeXmlHeader = includeXmlHeader; if (element != null) { String from = element.getAttributeValue("from"); String to = element.getAttributeValue("to"); if (from != null) { this.from = KixmppJid.fromRawJid(from); } else { this.from = null; } if (to != null) { this.to = KixmppJid.fromRawJid(to); } else { this.to = null; } this.id = element.getAttributeValue("id"); } else { this.from = null; this.to = null; this.id = null; } }
From source file:com.kixeye.kixmpp.server.module.muc.MucRoom.java
License:Apache License
/** * A user requests to join the room./*from ww w . j a va 2s.c o m*/ * * @param channel * @param nickname * @param mucStanza */ public void join(final Channel channel, String nickname, Element mucStanza) { KixmppJid jid = channel.attr(BindKixmppServerModule.JID).get(); if (settings.isOpen() && !jidRoles.containsKey(jid.withoutResource())) { addUser(jid, nickname, MucRole.Participant, MucAffiliation.Member); } verifyMembership(jid.withoutResource()); checkForNicknameInUse(nickname, jid); User user = usersByNickname.get(nickname); boolean existingUser = true; if (user == null) { user = new User(nickname, jid.withoutResource()); usersByNickname.put(nickname, user); MucRoomEventHandler handler = service.getServer().getMucRoomEventHandler(); if (handler != null) { handler.userAdded(this, user); } existingUser = false; } Client client = user.addClient(new Client(jid, nickname, channel)); // xep-0045 7.2.3 begin // self presence KixmppJid fromRoomJid = roomJid.withResource(nickname); channel.writeAndFlush(createPresence(fromRoomJid, jid, MucRole.Participant, null)); if (settings.isPresenceEnabled() && !existingUser) { // Send presence from existing occupants to new occupant sendExistingOccupantsPresenceToNewOccupant(user, channel); // Send new occupant's presence to all occupants broadcastPresence(fromRoomJid, MucRole.Participant, null); } // xep-0045 7.2.3 end if (settings.getSubject() != null) { Element message = new Element("message"); message.setAttribute("id", UUID.randomUUID().toString()); message.setAttribute("from", roomJid.withResource(nickname).toString()); message.setAttribute("to", channel.attr(BindKixmppServerModule.JID).get().toString()); message.setAttribute("type", "groupchat"); message.addContent(new Element("subject").setText(settings.getSubject())); channel.writeAndFlush(message); } if (mucStanza != null) { Element history = mucStanza.getChild("history", mucStanza.getNamespace()); if (history != null) { MucHistoryProvider historyProvider = mucModule.getHistoryProvider(); if (historyProvider != null) { Integer maxChars = null; Integer maxStanzas = null; Integer seconds = null; String parsableString = history.getAttributeValue("maxchars"); if (parsableString != null) { try { maxChars = Integer.parseInt(parsableString); } catch (Exception e) { } } parsableString = history.getAttributeValue("maxstanzas"); if (parsableString != null) { try { maxStanzas = Integer.parseInt(parsableString); } catch (Exception e) { } } parsableString = history.getAttributeValue("seconds"); if (parsableString != null) { try { seconds = Integer.parseInt(parsableString); } catch (Exception e) { } } String since = history.getAttributeValue("since"); historyProvider.getHistory(roomJid, user.getBareJid(), maxChars, maxStanzas, seconds, since) .addListener(new GenericFutureListener<Future<List<MucHistory>>>() { @Override public void operationComplete(Future<List<MucHistory>> future) throws Exception { if (future.isSuccess()) { List<MucHistory> historyItems = future.get(); if (historyItems != null) { for (MucHistory historyItem : historyItems) { Element message = new Element("message") .setAttribute("id", UUID.randomUUID().toString()) .setAttribute("from", roomJid.withResource(historyItem.getNickname()) .toString()) .setAttribute("to", channel.attr(BindKixmppServerModule.JID).get() .toString()) .setAttribute("type", "groupchat"); message.addContent( new Element("body").setText(historyItem.getBody())); Element addresses = new Element("addresses", Namespace .getNamespace("http://jabber.org/protocol/address")); addresses .addContent(new Element("address", addresses.getNamespace()) .setAttribute("type", "ofrom").setAttribute("jid", historyItem.getFrom().toString())); message.addContent(addresses); message.addContent(new Element("delay", Namespace.getNamespace("urn:xmpp:delay")) .setAttribute("from", roomJid.toString()) .setAttribute("stamp", XmppDateUtils .format(historyItem.getTimestamp()))); channel.write(message); } channel.flush(); } } } }); } } } channel.closeFuture().addListener(new CloseChannelListener(client)); }
From source file:com.novell.ldapchai.impl.edir.NmasResponseSet.java
License:Open Source License
static List<Challenge> parseNmasPolicyXML(final String str, final Locale locale) throws IOException, JDOMException { final List<Challenge> returnList = new ArrayList<Challenge>(); final Reader xmlreader = new StringReader(str); final SAXBuilder builder = new SAXBuilder(); final Document doc = builder.build(xmlreader); final boolean required = doc.getRootElement().getName().equals("RequiredQuestions"); for (Iterator qIter = doc.getDescendants(new ElementFilter("Question")); qIter.hasNext();) { final Element loopQ = (Element) qIter.next(); final int maxLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MaxLength"), 255); final int minLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MinLength"), 1); final String challengeText = readDisplayString(loopQ, locale); final Challenge challenge = new ChaiChallenge(required, challengeText, minLength, maxLength, true, 0, false);/*from ww w.ja v a 2 s . c om*/ returnList.add(challenge); } for (Iterator iter = doc.getDescendants(new ElementFilter("UserDefined")); iter.hasNext();) { final Element loopQ = (Element) iter.next(); final int maxLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MaxLength"), 255); final int minLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MinLength"), 1); final Challenge challenge = new ChaiChallenge(required, null, minLength, maxLength, false, 0, false); returnList.add(challenge); } return returnList; }
From source file:com.novell.ldapchai.impl.edir.NmasResponseSet.java
License:Open Source License
static ChallengeSet parseNmasUserResponseXML(final String str) throws IOException, JDOMException, ChaiValidationException { final List<Challenge> returnList = new ArrayList<Challenge>(); final Reader xmlreader = new StringReader(str); final SAXBuilder builder = new SAXBuilder(); final Document doc = builder.build(xmlreader); final Element rootElement = doc.getRootElement(); final int minRandom = StringHelper.convertStrToInt(rootElement.getAttributeValue("RandomQuestions"), 0); final String guidValue; {/*from ww w.j a va 2s . c o m*/ final Attribute guidAttribute = rootElement.getAttribute("GUID"); guidValue = guidAttribute == null ? null : guidAttribute.getValue(); } for (Iterator iter = doc.getDescendants(new ElementFilter("Challenge")); iter.hasNext();) { final Element loopQ = (Element) iter.next(); final int maxLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MaxLength"), 255); final int minLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MinLength"), 2); final String defineStrValue = loopQ.getAttributeValue("Define"); final boolean adminDefined = defineStrValue.equalsIgnoreCase("Admin"); final String typeStrValue = loopQ.getAttributeValue("Type"); final boolean required = typeStrValue.equalsIgnoreCase("Required"); final String challengeText = loopQ.getText(); final Challenge challenge = new ChaiChallenge(required, challengeText, minLength, maxLength, adminDefined, 0, false); returnList.add(challenge); } return new ChaiChallengeSet(returnList, minRandom, null, guidValue); }