This commit is contained in:
Igor I
2025-07-03 12:13:37 +05:00
5 changed files with 15 additions and 54 deletions

View File

@ -53,28 +53,28 @@ public class DBTools {
//if($t=='object' && (strtoupper($v)!='NULL' && gettype($v)=='string')) $t='string'; //Если id шники uuid //if($t=='object' && (strtoupper($v)!='NULL' && gettype($v)=='string')) $t='string'; //Если id шники uuid
if (t.equals("object") || t.equals("uid")) { if (t.equals("object") || t.equals("uid")) {
if (v.equals("")) if (v.isEmpty())
v = "NULL"; v = "NULL";
} else if (t.equals("i4") || t.equals("integer")) { } else if (t.equals("i4") || t.equals("integer")) {
if (v.equals("")) if (v.isEmpty())
v = "NULL"; v = "NULL";
} else if (t.equals("f8")) { } else if (t.equals("f8")) {
if (v.equals("")) if (v.isEmpty())
v = "NULL"; v = "NULL";
v = Tools.replaceAll(v,",", "."); //The decimal part: point. v = Tools.replaceAll(v,",", "."); //The decimal part: point.
} else if (t.equals("f4")) { } else if (t.equals("f4")) {
if (v.equals("")) if (v.isEmpty())
v = "NULL"; v = "NULL";
v = Tools.replaceAll(v,",", "."); //The decimal part: point. v = Tools.replaceAll(v,",", "."); //The decimal part: point.
} else if (t.equals("b")) { } else if (t.equals("b")) {
if (v.equals("")) if (v.isEmpty())
v = "NULL"; v = "NULL";
else if (v.equals("1")) else if (v.equals("1"))
v = "true"; v = "true";
else if (v.equals("0")) else if (v.equals("0"))
v = "false"; v = "false";
} else if (t.equals("string") || t.equals("text") || t.equals("dateTime") || t.equals("date")) { } else if (t.equals("string") || t.equals("text") || t.equals("dateTime") || t.equals("date")) {
if (v.equals("")) { if (v.isEmpty()) {
v = "NULL"; v = "NULL";
} else { } else {
v = Tools.replaceAll(v,"'", "''"); v = Tools.replaceAll(v,"'", "''");

View File

@ -494,7 +494,7 @@ public class TCField
}else if(type== TCField.BD_UTF8_1 || type== TCField.BD_UTF8_1_UUID || type== TCField.BD_UTF8_1_TIMESTAMP || this.type== TCField.BD_SUINT8 || this.type== TCField.BD_SINT8 || this.type== TCField.BD_SFLOAT8) }else if(type== TCField.BD_UTF8_1 || type== TCField.BD_UTF8_1_UUID || type== TCField.BD_UTF8_1_TIMESTAMP || this.type== TCField.BD_SUINT8 || this.type== TCField.BD_SINT8 || this.type== TCField.BD_SFLOAT8)
{ {
value=null; value=null;
if(val!=null && !val.equals("")) if(val!=null && !val.isEmpty())
{ {
byte[] b=null; byte[] b=null;
try { try {
@ -517,7 +517,7 @@ public class TCField
}else if(type== TCField.BD_UTF8_2) }else if(type== TCField.BD_UTF8_2)
{ {
value=null; value=null;
if(val!=null && !val.equals("")) if(val!=null && !val.isEmpty())
{ {
byte[] b=null; byte[] b=null;
try { try {
@ -541,7 +541,7 @@ public class TCField
}else if(type== TCField.BD_UTF8_4 || type== TCField.BD_UTF8_4_JSONB) }else if(type== TCField.BD_UTF8_4 || type== TCField.BD_UTF8_4_JSONB)
{ {
value=null; value=null;
if(val!=null && !val.equals("")) if(val!=null && !val.isEmpty())
{ {
byte[] b=null; byte[] b=null;
try { try {

View File

@ -123,8 +123,7 @@ public class Tools {
try { try {
InetAddress ipAddr = InetAddress.getByName("google.com"); InetAddress ipAddr = InetAddress.getByName("google.com");
//InetAddress ipAddr = InetAddress.getByName("geovizor.com"); //InetAddress ipAddr = InetAddress.getByName("geovizor.com");
//You can replace it with your name return ipAddr.isReachable(5000);
return !ipAddr.equals("");
} catch (Exception ex) { } catch (Exception ex) {
return false; return false;
} }
@ -1042,10 +1041,10 @@ public class Tools {
if((str.charAt(i)=='-' && (val.length()==0 || val.charAt(0)!='-')) || str.charAt(i)=='0' || str.charAt(i)=='1' || str.charAt(i)=='2' || str.charAt(i)=='3' || str.charAt(i)=='4' || str.charAt(i)=='5' || str.charAt(i)=='6' || str.charAt(i)=='7' || str.charAt(i)=='8' || str.charAt(i)=='9') if((str.charAt(i)=='-' && (val.length()==0 || val.charAt(0)!='-')) || str.charAt(i)=='0' || str.charAt(i)=='1' || str.charAt(i)=='2' || str.charAt(i)=='3' || str.charAt(i)=='4' || str.charAt(i)=='5' || str.charAt(i)=='6' || str.charAt(i)=='7' || str.charAt(i)=='8' || str.charAt(i)=='9')
val.append(str.charAt(i)); val.append(str.charAt(i));
} }
if(val.toString().equals("")) return 0; if(val.toString().isEmpty()) return 0;
return Integer.parseInt(val.toString()); return Integer.parseInt(val.toString());
} }
if(str.equals("")) return 0; if(str.isEmpty()) return 0;
return Integer.parseInt(str); return Integer.parseInt(str);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
package tools.xml; package tools.xmltools;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;

View File

@ -1,4 +1,4 @@
package tools.xml; package tools.xmltools;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;
@ -152,24 +152,6 @@ public class XMLTools
return lsSerializer.writeToString(node); return lsSerializer.writeToString(node);
} }
/** Найти узел по атрибуту
*/
public static Node findNodeOnAttribute(Node node, String nodename, String attribute, String val)
{
if(node==null) return null;
NodeList items = node.getChildNodes();
for (int i=0;i<items.getLength();i++)
{
Node n=items.item(i);
if(n.getNodeName().equals(nodename))
{
NamedNodeMap nnm=n.getAttributes();
if(nnm.getNamedItem(attribute).getNodeValue().equals(val)) return n;
}
}
return null;
}
public static Node findFirstNodeOnAttribute(Node node, String nodename,String attribute,String val) public static Node findFirstNodeOnAttribute(Node node, String nodename,String attribute,String val)
{ {
Node result=null; Node result=null;
@ -182,7 +164,7 @@ public class XMLTools
expr = xpath.compile("//*/"+nodename+"[@"+attribute+"='" + val + "']"); expr = xpath.compile("//*/"+nodename+"[@"+attribute+"='" + val + "']");
exprResult = expr.evaluate(node, XPathConstants.NODESET); exprResult = expr.evaluate(node, XPathConstants.NODESET);
} catch (XPathExpressionException ex) { } catch (XPathExpressionException ex) {
} }
NodeList nodeList = (NodeList) exprResult; NodeList nodeList = (NodeList) exprResult;
if (nodeList.getLength() > 0) if (nodeList.getLength() > 0)
@ -255,26 +237,6 @@ public class XMLTools
return null; return null;
} }
public static Node findFirstNodeOnAttribute(Node node, String nodename,String attribute,String val)
{
Node result=null;
if(node==null) return result;
javax.xml.xpath.XPathFactory xPathfactory = javax.xml.xpath.XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr=null;
Object exprResult=null;
try {
expr = xpath.compile("//*/"+nodename+"[@"+attribute+"='" + val + "']");
exprResult = expr.evaluate(node, XPathConstants.NODESET);
} catch (XPathExpressionException ex) {
}
NodeList nodeList = (NodeList) exprResult;
if (nodeList.getLength() > 0)
result = nodeList.item(0);
return result;
}
/** /**
* Присвоить дочерние узлы первого дерева второму если их нет, иначе дополнить либо заменить. (Работает через рекурсию нужно для передачи параметров между окнами) * Присвоить дочерние узлы первого дерева второму если их нет, иначе дополнить либо заменить. (Работает через рекурсию нужно для передачи параметров между окнами)
* @param {XML} first Узел где ханятся настройки * @param {XML} first Узел где ханятся настройки