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