1

I have a problem procesing some java classes that I can't understand why it happens, it doesn't have any logic to me.

I want to extract just the attributes of each class. I have (for example) class "oplyanxp.java":

private static final long serialVersionUID = 1584084300397L;
private OTrnPrcS oTrnPrcS = new OTrnPrcS();
private OPlyAnxS oPlyAnxS;

and class "oplyanxs.java":

private static final long serialVersionUID = 1584084300397L;
private java.math.BigDecimal  cmpVal;
private java.lang.String  qtnVal;
private java.lang.String  plyVal;

I run this script for each class:

awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$2" "$3}}' oplyanxp.java
awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$2" "$3}}' oplyanxs.java

and the result is ok:

oplyanxp.java

  private OTrnPrcS oTrnPrcS
  private OPlyAnxS oPlyAnxS;

oplyanxs.java

  private java.math.BigDecimal cmpVal;
  private java.lang.String qtnVal;
  private java.lang.String plyVal;

but if I change the parameter print order:

awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$3" "$2}}' oplyanxp.java
awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$3" "$2}}' oplyanxs.java

the result for class "oplyanxs.java" is fine:

  private cmpVal; java.math.BigDecimal
  private qtnVal; java.lang.String
  private plyVal; java.lang.String

but for class "oplyanxs.java" is wrong:

  private oTrnPrcS OTrnPrcS
   OPlyAnxSPlyAnxS;

I have also another class (oplyanxcpt.java) with more.less the same problem:

private static final long serialVersionUID = 1584084300397L;
private String prcTrmVal;
private List<OPlyAnxP> oPlyAnxPT;

awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$2" "$3}}' oplyanxcpt.java
private String prcTrmVal;
private List<OPlyAnxP> oPlyAnxPT;

awk '{if (($1 == "private") && ($5 != "serialVersionUID")) {print $1" "$3" "$2}}' oplyanxcpt.java
String prcTrmVal;
List<OPlyAnxP>PT;

I can't understand what the problem is, why it works for a class and not for the others. All files are in utf-8 encoding.

Anybody have any idea of the problem?

Inian
  • 80,270
  • 14
  • 142
  • 161

0 Answers0