diff --git a/src/org/atriasoft/exml/Attribute.java b/src/org/atriasoft/exml/Attribute.java index 35093b1..26cf7b9 100644 --- a/src/org/atriasoft/exml/Attribute.java +++ b/src/org/atriasoft/exml/Attribute.java @@ -14,25 +14,25 @@ import org.atriasoft.exml.internal.Tools; */ public class Attribute { - protected FilePos m_pos; //!< position in the read file (null if the file is not parsed); - protected String m_value; //!< value of the node (for element this is the name, for text it is the inside text ...); - protected String m_name; //!< Name of the attribute + protected FilePos pos; //!< position in the read file (null if the file is not parsed); + protected String value; //!< value of the node (for element this is the name, for text it is the inside text ...); + protected String name; //!< Name of the attribute public Attribute() { - this.m_pos = null; - this.m_value = ""; - this.m_name = ""; + this.pos = null; + this.value = ""; + this.name = ""; } public Attribute(final Attribute _obj) { - this.m_pos = null; - this.m_value = _obj.m_value; - this.m_name = _obj.m_name; + this.pos = null; + this.value = _obj.value; + this.name = _obj.name; } public Attribute(final String _name) { - this.m_name = _name; - this.m_value = ""; + this.name = _name; + this.value = ""; } /** @@ -41,12 +41,12 @@ public class Attribute { * @param[in] _value Value of the attribute. */ public Attribute(final String _name, final String _value) { - this.m_name = _name; - this.m_value = _value; + this.name = _name; + this.value = _value; } public void clear() { - this.m_value = ""; + this.value = ""; } @Override @@ -59,7 +59,7 @@ public class Attribute { * @return String of the attribute */ public String getName() { - return this.m_name; + return this.name; }; /** @@ -67,21 +67,21 @@ public class Attribute { * @return the reference of the string value. */ public String getValue() { - return this.m_value; + return this.value; }; protected boolean iGenerate(final StringBuilder _data, final int _indent) { _data.append(" "); - _data.append(this.m_name); + _data.append(this.name); _data.append("=\""); - _data.append(this.m_value); + _data.append(this.value); _data.append("\""); return true; }; protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { Log.verbose("start parse : 'attribute'"); - this.m_pos = _filePos.clone(); + this.pos = _filePos.clone(); // search end of the comment : int lastElementName = _pos.value; for (int iii = _pos.value; iii < _data.length(); iii++) { @@ -93,9 +93,9 @@ public class Attribute { break; } } - this.m_name = _data.substring(_pos.value, lastElementName + 1); + this.name = _data.substring(_pos.value, lastElementName + 1); if (_caseSensitive == true) { - this.m_name = this.m_name.toLowerCase(); + this.name = this.name.toLowerCase(); } // count white space : final FilePos tmpPos = new FilePos(); @@ -136,9 +136,9 @@ public class Attribute { break; } } - this.m_value = _data.substring(lastElementName + white + 2, lastAttributePos); + this.value = _data.substring(lastElementName + white + 2, lastAttributePos); - //EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); + //EXML_PARSE_ATTRIBUTE(pos << " attribute : " << name << "=\"" << value << "\""); _pos.value = lastAttributePos - 1; return true; @@ -153,9 +153,9 @@ public class Attribute { break; } } - this.m_value = _data.substring(lastElementName + white + 3, lastAttributePos); + this.value = _data.substring(lastElementName + white + 3, lastAttributePos); - //EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); + //EXML_PARSE_ATTRIBUTE(pos << " attribute : " << name << "=\"" << value << "\""); _pos.value = lastAttributePos; return true; @@ -166,7 +166,7 @@ public class Attribute { * @param[in] _name New name of the attribute */ public void setName(final String _name) { - this.m_name = _name; + this.name = _name; } /** @@ -174,6 +174,6 @@ public class Attribute { * @param[in] _value New value of the node. */ public final void setValue(final String _value) { - this.m_value = _value; + this.value = _value; } }; \ No newline at end of file diff --git a/src/org/atriasoft/exml/AttributeList.java b/src/org/atriasoft/exml/AttributeList.java index 39cf076..d508c7d 100644 --- a/src/org/atriasoft/exml/AttributeList.java +++ b/src/org/atriasoft/exml/AttributeList.java @@ -17,7 +17,7 @@ import org.atriasoft.exml.internal.Log; * @brief List of all attribute element in a node */ public abstract class AttributeList extends Node { - protected List m_listAttribute = new ArrayList<>(); //!< list of all attribute; + protected List listAttribute = new ArrayList<>(); //!< list of all attribute; public AttributeList() { super(); @@ -40,23 +40,23 @@ public abstract class AttributeList extends Node { Log.error("Try to set an empty node"); return; } - for (int iii = 0; iii < this.m_listAttribute.size(); iii++) { - if (this.m_listAttribute.get(iii) == _attr) { + for (int iii = 0; iii < this.listAttribute.size(); iii++) { + if (this.listAttribute.get(iii) == _attr) { Log.error("Try to add a node that is already added before !!!"); return; } - if (this.m_listAttribute.get(iii).getName().contentEquals(_attr.getName()) == true) { + if (this.listAttribute.get(iii).getName().contentEquals(_attr.getName()) == true) { Log.error("Try to add a node that is already added before (same name)"); return; } } - this.m_listAttribute.add(_attr); + this.listAttribute.add(_attr); } @Override public void clear() { super.clear(); - this.m_listAttribute.clear(); + this.listAttribute.clear(); }; /** @@ -68,8 +68,8 @@ public abstract class AttributeList extends Node { if (_name.length() == 0) { return false; } - for (int iii = 0; iii < this.m_listAttribute.size(); ++iii) { - if (this.m_listAttribute.get(iii) != null && this.m_listAttribute.get(iii).getName().contentEquals(_name) == true) { + for (int iii = 0; iii < this.listAttribute.size(); ++iii) { + if (this.listAttribute.get(iii) != null && this.listAttribute.get(iii).getName().contentEquals(_name) == true) { return true; } } @@ -83,10 +83,10 @@ public abstract class AttributeList extends Node { * @throws ExmlAttributeDoesNotExist The attribute does not exist. */ public Attribute getAttr(final int _id) throws ExmlAttributeDoesNotExist { - if (_id < 0 || _id >= this.m_listAttribute.size()) { - throw new ExmlAttributeDoesNotExist("Attribute does not exist: " + _id + "/" + this.m_listAttribute.size()); + if (_id < 0 || _id >= this.listAttribute.size()) { + throw new ExmlAttributeDoesNotExist("Attribute does not exist: " + _id + "/" + this.listAttribute.size()); } - return this.m_listAttribute.get(_id); + return this.listAttribute.get(_id); } /** @@ -99,16 +99,16 @@ public abstract class AttributeList extends Node { if (_name.length() == 0) { throw new ExmlAttributeDoesNotExist("Attribute can not have empty name"); } - for (int iii = 0; iii < this.m_listAttribute.size(); iii++) { - if (this.m_listAttribute.get(iii) != null && this.m_listAttribute.get(iii).getName().contentEquals(_name) == true) { - return this.m_listAttribute.get(iii).getValue(); + for (int iii = 0; iii < this.listAttribute.size(); iii++) { + if (this.listAttribute.get(iii) != null && this.listAttribute.get(iii).getName().contentEquals(_name) == true) { + return this.listAttribute.get(iii).getValue(); } } - throw new ExmlAttributeDoesNotExist("Attribute does not exist: " + _name + " in " + this.m_listAttribute.size() + " attributes"); + throw new ExmlAttributeDoesNotExist("Attribute does not exist: " + _name + " in " + this.listAttribute.size() + " attributes"); } public List getAttributes() { - return this.m_listAttribute; + return this.listAttribute; } /** @@ -124,9 +124,9 @@ public abstract class AttributeList extends Node { @Override protected boolean iGenerate(final StringBuilder _data, final int _indent) { - for (int iii = 0; iii < this.m_listAttribute.size(); iii++) { - if (this.m_listAttribute.get(iii) != null) { - this.m_listAttribute.get(iii).iGenerate(_data, _indent); + for (int iii = 0; iii < this.listAttribute.size(); iii++) { + if (this.listAttribute.get(iii) != null) { + this.listAttribute.get(iii).iGenerate(_data, _indent); } } return true; @@ -142,7 +142,7 @@ public abstract class AttributeList extends Node { if (_name.length() == 0) { return false; } - for (final ListIterator iter = this.m_listAttribute.listIterator(); iter.hasNext();) { + for (final ListIterator iter = this.listAttribute.listIterator(); iter.hasNext();) { final Attribute element = iter.next(); if (element == null) { iter.remove(); @@ -163,15 +163,15 @@ public abstract class AttributeList extends Node { */ public void setAttribute(final String _name, final String _value) { // check if attribute already det : - for (int iii = 0; iii < this.m_listAttribute.size(); ++iii) { - if (this.m_listAttribute.get(iii) != null && this.m_listAttribute.get(iii).getName().contentEquals(_name) == true) { + for (int iii = 0; iii < this.listAttribute.size(); ++iii) { + if (this.listAttribute.get(iii) != null && this.listAttribute.get(iii).getName().contentEquals(_name) == true) { // update the value : - this.m_listAttribute.get(iii).setValue(_value); + this.listAttribute.get(iii).setValue(_value); return; } } final Attribute attr = new Attribute(_name, _value); - this.m_listAttribute.add(attr); + this.listAttribute.add(attr); } /** @@ -179,6 +179,6 @@ public abstract class AttributeList extends Node { * @return Nulber of attribute >=0 */ public int sizeAttribute() { - return this.m_listAttribute.size(); + return this.listAttribute.size(); } } \ No newline at end of file diff --git a/src/org/atriasoft/exml/Comment.java b/src/org/atriasoft/exml/Comment.java index c9af10c..cc43e71 100644 --- a/src/org/atriasoft/exml/Comment.java +++ b/src/org/atriasoft/exml/Comment.java @@ -19,7 +19,7 @@ public class Comment extends Node { } public Comment(final Comment obj) { - super(obj.m_value); + super(obj.value); } /** @@ -44,7 +44,7 @@ public class Comment extends Node { public boolean iGenerate(final StringBuilder _data, final int _indent) { Tools.addIndent(_data, _indent); _data.append("\n"); return true; } @@ -52,7 +52,7 @@ public class Comment extends Node { @Override protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { Log.verbose("start parse : 'comment'"); - this.m_pos = _filePos; + this.pos = _filePos; final FilePos tmpPos = new FilePos(); final int white = Tools.countWhiteChar(_data, _pos.value, tmpPos); _filePos.add(tmpPos); @@ -74,8 +74,8 @@ public class Comment extends Node { } } // find end of value: - this.m_value = _data.substring(_pos.value + white, newEnd); - Log.verbose(" find comment '" + this.m_value + "'"); + this.value = _data.substring(_pos.value + white, newEnd); + Log.verbose(" find comment '" + this.value + "'"); _pos.value = iii + 2; return true; } diff --git a/src/org/atriasoft/exml/Declaration.java b/src/org/atriasoft/exml/Declaration.java index f8b56cf..dbbf6c9 100644 --- a/src/org/atriasoft/exml/Declaration.java +++ b/src/org/atriasoft/exml/Declaration.java @@ -18,9 +18,9 @@ public class Declaration extends AttributeList { }; public Declaration(final Declaration obj) { - super(obj.m_value); - for (final Attribute elem : obj.m_listAttribute) { - this.m_listAttribute.add(elem.clone()); + super(obj.value); + for (final Attribute elem : obj.listAttribute) { + this.listAttribute.add(elem.clone()); } }; @@ -46,7 +46,7 @@ public class Declaration extends AttributeList { protected boolean iGenerate(final StringBuilder _data, final int _indent) { Tools.addIndent(_data, _indent); _data.append("\n"); return true; @@ -54,8 +54,8 @@ public class Declaration extends AttributeList { @Override protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { - Log.verbose("start parse : 'declaration' : '" + this.m_value + "'"); - this.m_pos = _filePos; + Log.verbose("start parse : 'declaration' : '" + this.value + "'"); + this.pos = _filePos; // search end of the comment : for (int iii = _pos.value; iii + 1 < _data.length(); iii++) { Tools.drawElementParsed(_data.charAt(iii), _filePos); @@ -81,7 +81,7 @@ public class Declaration extends AttributeList { return false; } iii = _pos.value; - this.m_listAttribute.add(attribute); + this.listAttribute.add(attribute); continue; } } diff --git a/src/org/atriasoft/exml/DeclarationXML.java b/src/org/atriasoft/exml/DeclarationXML.java index d5bf32b..8dac26c 100644 --- a/src/org/atriasoft/exml/DeclarationXML.java +++ b/src/org/atriasoft/exml/DeclarationXML.java @@ -9,9 +9,9 @@ import org.atriasoft.exml.internal.Log; public class DeclarationXML extends Declaration { public DeclarationXML(final DeclarationXML obj) { - super(obj.m_value); - for (final Attribute elem : obj.m_listAttribute) { - this.m_listAttribute.add(elem.clone()); + super(obj.value); + for (final Attribute elem : obj.listAttribute) { + this.listAttribute.add(elem.clone()); } } diff --git a/src/org/atriasoft/exml/Document.java b/src/org/atriasoft/exml/Document.java index 906a7a1..178d9f3 100644 --- a/src/org/atriasoft/exml/Document.java +++ b/src/org/atriasoft/exml/Document.java @@ -19,21 +19,21 @@ import org.atriasoft.exml.internal.Tools; */ public class Document extends Element { - private boolean m_caseSensitive; //!< check the case sensitive of the nodes and attribute - private boolean m_writeErrorWhenDetexted; //!< Request print error in parsing just when detected - private String m_comment; //!< Comment on the error; - private String m_Line; //!< Parse line error (copy); - private FilePos m_filePos; //!< position of the error + private boolean caseSensitive; //!< check the case sensitive of the nodes and attribute + private boolean writeErrorWhenDetexted; //!< Request print error in parsing just when detected + private String comment; //!< Comment on the error; + private String Line; //!< Parse line error (copy); + private FilePos filePos; //!< position of the error /** * @brief Constructor */ public Document() { - this.m_caseSensitive = false; - this.m_writeErrorWhenDetexted = true; - this.m_comment = ""; - this.m_Line = ""; - this.m_filePos = new FilePos(0, 0); + this.caseSensitive = false; + this.writeErrorWhenDetexted = true; + this.comment = ""; + this.Line = ""; + this.filePos = new FilePos(0, 0); } @Override @@ -50,10 +50,10 @@ public class Document extends Element { * @param[in] _comment Error string to display */ public void createError(final String _data, final int _pos, final FilePos _filePos, final String _comment) { - this.m_comment = _comment; - this.m_Line = extract_line(_data, _pos); - this.m_filePos = _filePos; - if (this.m_writeErrorWhenDetexted == true) { + this.comment = _comment; + this.Line = extract_line(_data, _pos); + this.filePos = _filePos; + if (this.writeErrorWhenDetexted == true) { displayError(); } } @@ -71,11 +71,11 @@ public class Document extends Element { * @brief Request display in log of the error */ public void displayError() { - if (this.m_comment.length() == 0) { + if (this.comment.length() == 0) { Log.error("No error detected ???"); return; } - Log.error(this.m_filePos + " " + this.m_comment + "\n" + this.m_Line + "\n" + Tools.createPosPointer(this.m_Line, this.m_filePos.getCol())); + Log.error(this.filePos + " " + this.comment + "\n" + this.Line + "\n" + Tools.createPosPointer(this.Line, this.filePos.getCol())); //Log.critical("detect error"); } @@ -182,7 +182,7 @@ public class Document extends Element { * @return true if case sensitive is active */ public boolean getCaseSensitive() { - return this.m_caseSensitive; + return this.caseSensitive; } /** @@ -191,7 +191,7 @@ public class Document extends Element { * @return false Does not display error (get it at end) */ public boolean getDisplayError() { - return this.m_writeErrorWhenDetexted; + return this.writeErrorWhenDetexted; } @Override @@ -201,9 +201,9 @@ public class Document extends Element { @Override public boolean iGenerate(final StringBuilder _data, final int _indent) { - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) != null) { - this.m_listSub.get(iii).iGenerate(_data, _indent); + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) != null) { + this.listSub.get(iii).iGenerate(_data, _indent); } } return true; @@ -219,9 +219,9 @@ public class Document extends Element { Log.verbose("Start parsing document (type: string) size=" + _data.length()); clear(); // came from char == > force in utf8 ... - this.m_pos = new FilePos(1, 0); + this.pos = new FilePos(1, 0); final PositionParsing parsePos = new PositionParsing(); - return subParse(_data, parsePos, this.m_caseSensitive, this.m_pos, this, true); + return subParse(_data, parsePos, this.caseSensitive, this.pos, this, true); } /** @@ -230,7 +230,7 @@ public class Document extends Element { */ // TODO: Naming error, it is insensitive ... public void setCaseSensitive(final boolean _val) { - this.m_caseSensitive = _val; + this.caseSensitive = _val; } /** @@ -238,6 +238,6 @@ public class Document extends Element { * @param[in] _value true: display error, false not display error (get it at end) */ public void setDisplayError(final boolean _value) { - this.m_writeErrorWhenDetexted = _value; + this.writeErrorWhenDetexted = _value; } } diff --git a/src/org/atriasoft/exml/Element.java b/src/org/atriasoft/exml/Element.java index 08a8a14..ce9ebcc 100644 --- a/src/org/atriasoft/exml/Element.java +++ b/src/org/atriasoft/exml/Element.java @@ -23,7 +23,7 @@ import org.atriasoft.exml.internal.Tools; * @brief Basic element Node of an XML document lt;YYYYYgt; */ public class Element extends AttributeList { - protected List m_listSub = new ArrayList<>(); //!< List of subNodes; + protected List listSub = new ArrayList<>(); //!< List of subNodes; /** * @brief Constructor @@ -33,12 +33,12 @@ public class Element extends AttributeList { }; public Element(final Element obj) throws CloneNotSupportedException { - super(obj.m_value); - for (final Attribute elem : obj.m_listAttribute) { - this.m_listAttribute.add(elem.clone()); + super(obj.value); + for (final Attribute elem : obj.listAttribute) { + this.listAttribute.add(elem.clone()); } - for (final Node elem : obj.m_listSub) { - this.m_listSub.add(elem.clone()); + for (final Node elem : obj.listSub) { + this.listSub.add(elem.clone()); } } @@ -60,19 +60,19 @@ public class Element extends AttributeList { Log.error("Try to set an empty node"); return; } - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) == _node) { + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) == _node) { Log.error("Try to add a node that is already added before !!!"); return; } } - this.m_listSub.add(_node); + this.listSub.add(_node); } @Override public void clear() { super.clear(); - this.m_listSub.clear(); + this.listSub.clear(); }; @Override @@ -86,7 +86,7 @@ public class Element extends AttributeList { * @return true if the Node exist. */ public boolean existNode(final int _id) { - if (_id < 0 || _id >= this.m_listSub.size()) { + if (_id < 0 || _id >= this.listSub.size()) { return false; } return true; @@ -101,9 +101,9 @@ public class Element extends AttributeList { if (_name.isEmpty() == true) { return false; } - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) != null && this.m_listSub.get(iii).getValue().contentEquals(_name) == true) { - if (this.m_listSub.get(iii) == null) { + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) != null && this.listSub.get(iii).getValue().contentEquals(_name) == true) { + if (this.listSub.get(iii) == null) { return false; } return true; @@ -119,10 +119,10 @@ public class Element extends AttributeList { * @throws ExmlNodeDoesNotExist The Node does not exist */ public Node getNode(final int _id) throws ExmlNodeDoesNotExist { - if (_id < 0 || _id >= this.m_listSub.size()) { - throw new ExmlNodeDoesNotExist("Node does not exist: " + _id + "/" + this.m_listSub.size()); + if (_id < 0 || _id >= this.listSub.size()) { + throw new ExmlNodeDoesNotExist("Node does not exist: " + _id + "/" + this.listSub.size()); } - return this.m_listSub.get(_id); + return this.listSub.get(_id); } /** @@ -133,14 +133,14 @@ public class Element extends AttributeList { */ public Node getNode(final String _name) throws ExmlNodeDoesNotExist { if (_name.isEmpty() == true) { - throw new ExmlNodeDoesNotExist("Node can not have empty name in " + this.m_listAttribute.size() + " nodes"); + throw new ExmlNodeDoesNotExist("Node can not have empty name in " + this.listAttribute.size() + " nodes"); } - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) != null && this.m_listSub.get(iii).getValue().contentEquals(_name) == true) { - return this.m_listSub.get(iii); + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) != null && this.listSub.get(iii).getValue().contentEquals(_name) == true) { + return this.listSub.get(iii); } } - throw new ExmlNodeDoesNotExist("Node does not exist: '" + _name + "' in " + this.m_listAttribute.size()); + throw new ExmlNodeDoesNotExist("Node does not exist: '" + _name + "' in " + this.listAttribute.size()); } /** @@ -148,7 +148,7 @@ public class Element extends AttributeList { * @return List of current nodes. */ public List getNodes() { - return this.m_listSub; + return this.listSub; } /** @@ -157,16 +157,16 @@ public class Element extends AttributeList { */ public String getText() { final StringBuilder res = new StringBuilder(); - if (this.m_listSub.size() == 1) { - if (this.m_listSub.get(0).getType() == NodeType.TEXT) { - res.append(this.m_listSub.get(0).getValue()); + if (this.listSub.size() == 1) { + if (this.listSub.get(0).getType() == NodeType.TEXT) { + res.append(this.listSub.get(0).getValue()); } else { - this.m_listSub.get(0).iGenerate(res, 0); + this.listSub.get(0).iGenerate(res, 0); } } else { - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) != null) { - this.m_listSub.get(iii).iGenerate(res, 0); + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) != null) { + this.listSub.get(iii).iGenerate(res, 0); } } } @@ -185,35 +185,35 @@ public class Element extends AttributeList { * @throws ExmlNodeDoesNotExist The Node does not exist */ public NodeType getType(final int _id) throws ExmlNodeDoesNotExist { - if (_id < 0 || _id >= this.m_listSub.size()) { - throw new ExmlNodeDoesNotExist("Node does not exist: " + _id + "/" + this.m_listSub.size()); + if (_id < 0 || _id >= this.listSub.size()) { + throw new ExmlNodeDoesNotExist("Node does not exist: " + _id + "/" + this.listSub.size()); } - return this.m_listSub.get(_id).getType(); + return this.listSub.get(_id).getType(); } @Override protected boolean iGenerate(final StringBuilder _data, final int _indent) { Tools.addIndent(_data, _indent); _data.append("<"); - _data.append(this.m_value); + _data.append(this.value); super.iGenerate(_data, _indent); - if (this.m_listSub.size() > 0) { - if (this.m_listSub.size() == 1 && this.m_listSub.get(0) != null && this.m_listSub.get(0).getType() == NodeType.TEXT && ((Text) this.m_listSub.get(0)).countLines() == 1) { + if (this.listSub.size() > 0) { + if (this.listSub.size() == 1 && this.listSub.get(0) != null && this.listSub.get(0).getType() == NodeType.TEXT && ((Text) this.listSub.get(0)).countLines() == 1) { _data.append(">"); - this.m_listSub.get(0).iGenerate(_data, 0); + this.listSub.get(0).iGenerate(_data, 0); Log.verbose(" generate : '" + _data + "'"); } else { _data.append(">\n"); - for (int iii = 0; iii < this.m_listSub.size(); iii++) { - if (this.m_listSub.get(iii) != null) { - this.m_listSub.get(iii).iGenerate(_data, _indent + 1); + for (int iii = 0; iii < this.listSub.size(); iii++) { + if (this.listSub.get(iii) != null) { + this.listSub.get(iii).iGenerate(_data, _indent + 1); } } Tools.addIndent(_data, _indent); } _data.append("\n"); } else { _data.append("/>\n"); @@ -223,9 +223,9 @@ public class Element extends AttributeList { @Override protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { - //EXML_PARSE_ELEMENT("start parse : 'element' named='" + m_value + "'"); + //EXML_PARSE_ELEMENT("start parse : 'element' named='" + value + "'"); // note : When start parsing the upper element must have set the value of the element and set the position after this one - this.m_pos = _filePos.clone(); + this.pos = _filePos.clone(); // find a normal node ... for (int iii = _pos.value; iii < _data.length(); iii++) { _filePos.check(_data.charAt(iii)); @@ -258,7 +258,7 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listAttribute.add(attribute); + this.listAttribute.add(attribute); continue; } if (Tools.isWhiteChar(_data.charAt(iii)) == false) { @@ -266,7 +266,7 @@ public class Element extends AttributeList { return false; } } - _doc.createError(_data, _pos.value, _filePos, "Unexpecting end of parsing exml::internal::Element : '" + this.m_value + "' == > check if the '/>' is set or the end of element"); + _doc.createError(_data, _pos.value, _filePos, "Unexpecting end of parsing exml::internal::Element : '" + this.value + "' == > check if the '/>' is set or the end of element"); return false; } @@ -278,7 +278,7 @@ public class Element extends AttributeList { if (_nodeName == "") { return; } - for (final ListIterator iter = this.m_listSub.listIterator(); iter.hasNext();) { + for (final ListIterator iter = this.listSub.listIterator(); iter.hasNext();) { final Node element = iter.next(); if (element == null) { iter.remove(); @@ -295,7 +295,7 @@ public class Element extends AttributeList { * @return a number >=0. */ public int size() { - return this.m_listSub.size(); + return this.listSub.size(); } /** @@ -366,7 +366,7 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listSub.add(declaration); + this.listSub.add(declaration); continue; } if (_data.charAt(iii + white + 1) == '!') { @@ -395,7 +395,7 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listSub.add(comment); + this.listSub.add(comment); } else if (_data.charAt(iii + white + 2) == '[') { tmpPos.increment(); if (iii + white + 8 >= _data.length()) { @@ -417,7 +417,7 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listSub.add(text); + this.listSub.add(text); } else { _doc.createError(_data, _pos.value, _filePos, "End file with ' invalide XML"); return false; @@ -442,7 +442,7 @@ public class Element extends AttributeList { if (_caseSensitive == true) { tmpname = tmpname.toLowerCase(); } - if (tmpname.contentEquals(this.m_value) == true) { + if (tmpname.contentEquals(this.value) == true) { // find end of node : // find > element ... for (int jjj = endPosName + 1; jjj < _data.length(); jjj++) { @@ -456,12 +456,12 @@ public class Element extends AttributeList { return true; } else if (_data.charAt(jjj) != '\r' && _data.charAt(jjj) != ' ' && _data.charAt(jjj) != '\t') { _filePos.add(tmpPos); - _doc.createError(_data, jjj, _filePos, "End node error : have data inside end node other than [ \\n\\t\\r] " + this.m_value + "'"); + _doc.createError(_data, jjj, _filePos, "End node error : have data inside end node other than [ \\n\\t\\r] " + this.value + "'"); return false; } } } else { - _doc.createError(_data, _pos.value, _filePos, "End node error : '" + tmpname + "' != '" + this.m_value + "'"); + _doc.createError(_data, _pos.value, _filePos, "End node error : '" + tmpname + "' != '" + this.value + "'"); return false; } } @@ -498,7 +498,7 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listSub.add(element); + this.listSub.add(element); continue; } _filePos.add(tmpPos); @@ -522,14 +522,14 @@ public class Element extends AttributeList { return false; } iii = _pos.value; - this.m_listSub.add(text); + this.listSub.add(text); } } } if (_mainNode == true) { return true; } - _doc.createError(_data, _pos.value, _filePos, "Did not find end of the exml::internal::Element : '" + this.m_value + "'"); + _doc.createError(_data, _pos.value, _filePos, "Did not find end of the exml::internal::Element : '" + this.value + "'"); return false; } diff --git a/src/org/atriasoft/exml/FilePos.java b/src/org/atriasoft/exml/FilePos.java index f822495..785e10f 100644 --- a/src/org/atriasoft/exml/FilePos.java +++ b/src/org/atriasoft/exml/FilePos.java @@ -15,15 +15,15 @@ package org.atriasoft.exml; * @brief Position in the file of the original data. */ public class FilePos { - private int m_col; //!< source text colomn - private int m_line; //!< source Line colomn + private int col; //!< source text colomn + private int line; //!< source Line colomn /** * @brief default contructor (set line and col at 0) */ public FilePos() { - this.m_col = 0; - this.m_line = 0; + this.col = 0; + this.line = 0; } /** @@ -32,8 +32,8 @@ public class FilePos { * @param[in] _col Colomn in the file */ public FilePos(final int _line, final int _col) { - this.m_col = _col; - this.m_line = _line; + this.col = _col; + this.line = _line; } /** @@ -42,11 +42,11 @@ public class FilePos { * @return Reference on this */ public FilePos add(final FilePos _obj) { - if (_obj.m_line == 0) { - this.m_col += _obj.m_col; + if (_obj.line == 0) { + this.col += _obj.col; } else { - this.m_col = _obj.m_col; - this.m_line += _obj.m_line; + this.col = _obj.col; + this.line += _obj.line; } return this; } @@ -57,7 +57,7 @@ public class FilePos { * @return Reference on this */ public FilePos add(final int _col) { - this.m_col += _col; + this.col += _col; return this; } @@ -68,7 +68,7 @@ public class FilePos { * @return false We NOT find a new line */ public boolean check(final Character _val) { - this.m_col++; + this.col++; if (_val == '\n') { newLine(); return true; @@ -80,15 +80,15 @@ public class FilePos { * @brief Reset position at 0,0 */ public void clear() { - this.m_col = 0; - this.m_line = 0; + this.col = 0; + this.line = 0; } @Override public FilePos clone() { final FilePos out = new FilePos(); - out.m_col = this.m_col; - out.m_line = this.m_line; + out.col = this.col; + out.line = this.line; return out; } @@ -97,7 +97,7 @@ public class FilePos { * @return Reference on this */ public FilePos decrement() { - this.m_col--; + this.col--; return this; } @@ -110,7 +110,7 @@ public class FilePos { return false; } final FilePos other = (FilePos) obj; - return this.m_col == other.m_col && this.m_line == other.m_line; + return this.col == other.col && this.line == other.line; } /** @@ -118,7 +118,7 @@ public class FilePos { * @return Colomn in number of utf8-char */ public int getCol() { - return this.m_col; + return this.col; } /** @@ -126,12 +126,12 @@ public class FilePos { * @return line ID (start at 0) */ public int getLine() { - return this.m_line; + return this.line; } @Override public int hashCode() { - return super.hashCode() + this.m_line + this.m_col; + return super.hashCode() + this.line + this.col; } /** @@ -139,7 +139,7 @@ public class FilePos { * @return Reference on this */ public FilePos increment() { - this.m_col++; + this.col++; return this; } @@ -147,8 +147,8 @@ public class FilePos { * @brief Find a new line & reset colomn at 0 */ public void newLine() { - this.m_col = 0; - this.m_line++; + this.col = 0; + this.line++; } /** @@ -157,8 +157,8 @@ public class FilePos { * @return Reference on this */ public FilePos set(final FilePos _obj) { - this.m_col = _obj.m_col; - this.m_line = _obj.m_line; + this.col = _obj.col; + this.line = _obj.line; return this; } @@ -168,16 +168,16 @@ public class FilePos { * @param[in] _col Colomn in the file */ public void set(final int _line, final int _col) { - this.m_col = _col; - this.m_line = _line; + this.col = _col; + this.line = _line; } @Override public String toString() { String out = "(l="; - out += this.m_line; + out += this.line; out += ",c="; - out += this.m_col; + out += this.col; out += ")"; return out; } diff --git a/src/org/atriasoft/exml/Node.java b/src/org/atriasoft/exml/Node.java index 1bb7b1b..2d7376c 100644 --- a/src/org/atriasoft/exml/Node.java +++ b/src/org/atriasoft/exml/Node.java @@ -12,14 +12,14 @@ import org.atriasoft.exml.internal.PositionParsing; */ public abstract class Node { - protected FilePos m_pos; //!< position in the read file (null if the file is not parsed) - protected String m_value; //!< value of the node (for element this is the name, for text it is the inside text ...); + protected FilePos pos; //!< position in the read file (null if the file is not parsed) + protected String value; //!< value of the node (for element this is the name, for text it is the inside text ...); /** * @brief basic element of a xml structure */ public Node() { - this.m_pos = null; + this.pos = null; } /** @@ -27,16 +27,16 @@ public abstract class Node { * @param[in] _value value of the node */ public Node(final String _value) { - this.m_pos = null; - this.m_value = _value; + this.pos = null; + this.value = _value; } /** * @brief clear the Node */ public void clear() { - this.m_value = ""; - this.m_pos = null; + this.value = ""; + this.pos = null; } @Override @@ -49,7 +49,7 @@ public abstract class Node { * @return The file position reference */ public FilePos getPos() { - return this.m_pos; + return this.pos; } /** @@ -63,7 +63,7 @@ public abstract class Node { * @return the reference of the string value. */ public String getValue() { - return this.m_value; + return this.value; } /** @@ -131,7 +131,7 @@ public abstract class Node { */ public final void setValue(final String _value) { - this.m_value = _value; + this.value = _value; } /** diff --git a/src/org/atriasoft/exml/Text.java b/src/org/atriasoft/exml/Text.java index 2d21e1a..e3e96d5 100644 --- a/src/org/atriasoft/exml/Text.java +++ b/src/org/atriasoft/exml/Text.java @@ -61,8 +61,8 @@ public class Text extends Node { */ protected int countLines() { int count = 1; - for (int iii = 0; iii < this.m_value.length(); iii++) { - if (this.m_value.charAt(iii) == '\n') { + for (int iii = 0; iii < this.value.length(); iii++) { + if (this.value.charAt(iii) == '\n') { count++; } } @@ -76,14 +76,14 @@ public class Text extends Node { @Override protected boolean iGenerate(final StringBuilder _data, final int _indent) { - _data.append(replaceSpecialCharOut(this.m_value)); + _data.append(replaceSpecialCharOut(this.value)); return true; } @Override protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { Log.verbose("start parse : 'text'"); - this.m_pos = _filePos.clone(); + this.pos = _filePos.clone(); // search end of the comment : for (int iii = _pos.value; iii < _data.length(); iii++) { Tools.drawElementParsed(_data.charAt(iii), _filePos); @@ -101,10 +101,10 @@ public class Text extends Node { } } // find end of value: - this.m_value = _data.substring(_pos.value, newEnd); - Log.verbose(" find text '" + this.m_value + "'"); + this.value = _data.substring(_pos.value, newEnd); + Log.verbose(" find text '" + this.value + "'"); _pos.value = iii - 1; - this.m_value = replaceSpecialChar(this.m_value); + this.value = replaceSpecialChar(this.value); return true; } } diff --git a/src/org/atriasoft/exml/TextCDATA.java b/src/org/atriasoft/exml/TextCDATA.java index 43b755f..d06e0ea 100644 --- a/src/org/atriasoft/exml/TextCDATA.java +++ b/src/org/atriasoft/exml/TextCDATA.java @@ -21,7 +21,7 @@ public class TextCDATA extends Text { @Override protected boolean iGenerate(final StringBuilder _data, final int _indent) { _data.append(""); return true; } @@ -29,7 +29,7 @@ public class TextCDATA extends Text { @Override protected boolean iParse(final String _data, final PositionParsing _pos, final boolean _caseSensitive, final FilePos _filePos, final Document _doc) { Log.verbose("start parse : 'text::CDATA'"); - this.m_pos = _filePos.clone(); + this.pos = _filePos.clone(); // search end of the comment : for (int iii = _pos.value; iii + 2 < _data.length(); iii++) { Tools.drawElementParsed(_data.charAt(iii), _filePos); @@ -39,8 +39,8 @@ public class TextCDATA extends Text { if (_data.charAt(iii) == ']' && _data.charAt(iii + 1) == ']' && _data.charAt(iii + 2) == '>') { // find end of value: _filePos.add(2); - this.m_value = _data.substring(_pos.value, iii); - Log.verbose(" find text CDATA '" + this.m_value + "'"); + this.value = _data.substring(_pos.value, iii); + Log.verbose(" find text CDATA '" + this.value + "'"); _pos.value = iii + 2; return true; } diff --git a/test/src/test/atriasoft/exml/ExmlTestElement.java b/test/src/test/atriasoft/exml/ExmlTestElement.java index 376e6f9..09950d5 100644 --- a/test/src/test/atriasoft/exml/ExmlTestElement.java +++ b/test/src/test/atriasoft/exml/ExmlTestElement.java @@ -109,7 +109,7 @@ public class ExmlTestElement { @Test public void getTypeId() { final Element myElement = new Element("NodeName"); - Assertions.assertEquals(NodeType.UNKNOWN, myElement.getType(1)); + Assertions.assertThrows(ExmlNodeDoesNotExist.class, () -> myElement.getType(1)); } @Test