Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 57465200D59 for ; Sun, 10 Dec 2017 22:46:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 55B47160C09; Sun, 10 Dec 2017 21:46:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9AE46160BF2 for ; Sun, 10 Dec 2017 22:46:09 +0100 (CET) Received: (qmail 26649 invoked by uid 500); 10 Dec 2017 21:46:03 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 26638 invoked by uid 99); 10 Dec 2017 21:46:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 Dec 2017 21:46:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2152518073A for ; Sun, 10 Dec 2017 21:46:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id JCHt9m-JKX8P for ; Sun, 10 Dec 2017 21:46:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 339605FB2D for ; Sun, 10 Dec 2017 21:46:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 611B6E015F for ; Sun, 10 Dec 2017 21:46:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 19DE4212FC for ; Sun, 10 Dec 2017 21:46:00 +0000 (UTC) Date: Sun, 10 Dec 2017 21:46:00 +0000 (UTC) From: "Ate Douma (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SCXML-240) adding user-defined properties to the state model MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 10 Dec 2017 21:46:10 -0000 [ https://issues.apache.org/jira/browse/SCXML-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ate Douma updated SCXML-240: ---------------------------- Fix Version/s: (was: 2.0) > adding user-defined properties to the state model > ------------------------------------------------- > > Key: SCXML-240 > URL: https://issues.apache.org/jira/browse/SCXML-240 > Project: Commons SCXML > Issue Type: Improvement > Affects Versions: 2.0 > Reporter: Jacob Saoumi > Labels: patch > > Hello, > I need to extend the state model to have user-defined properties. For example: > > The solution is to easy. Add the following methods to the org.apache.commons.scxml2.model.State class: > /** > * set a user-defined property with the given {@code name} > * > * @param name > * the name of the user-defined propery > * @param value > * the value of the property > */ > public final synchronized void setProperty(String name, String value) > { > if (this.extendProperties == null) { > this.extendProperties = new HashMap(); > } > this.extendProperties.put(name, value); > } > /** > * > * @param name > * the name of the user-defined propery > * @return the value of the property with the given {@code name} > */ > public final String getProperty(String name) > { > return extendProperties == null ? null : extendProperties.get(name); > } > /** > * > * @return a set of user-defined properties names > */ > public final Set getPropertyNames() > { > return extendProperties == null ? null : extendProperties.keySet(); > } > /** > * > * @return the count of the user-defined properties > */ > public final int getPropertyCount() > { > return extendProperties == null ? 0 : extendProperties.size(); > } > and extend the readState method of the SCXMLReader to read this properties from xml: > // reading user-defined properties > int attrCount = reader.getAttributeCount(); > for (int i = 0; i < attrCount; i++) { > QName attrName = reader.getAttributeName(i); > String prefix = nullIfEmpty(attrName.getPrefix()); > String localPart = attrName.getLocalPart(); > if (prefix != null) { > localPart = prefix + ":" + localPart; > } > if (ATTR_SRC.equals(localPart) || TTR_INITIAL.equals(localPart) || ATTR_ID.equals(localPart)) { > continue; > } > state.setProperty(localPart, reader.getAttributeValue(i)); > } -- This message was sent by Atlassian JIRA (v6.4.14#64029)