├── .gitignore ├── LICENSE ├── README-zh.md ├── README.md ├── lib ├── gson-2.9.0.jar ├── jackson-annotations-2.13.3.jar ├── jackson-core-2.13.3.jar └── jackson-databind-2.13.3.jar └── src └── main ├── java └── com │ └── aixcode │ ├── autoTest │ ├── AbstractBaseEvaluation.java │ ├── Executor.java │ ├── GenerateMethodBase.java │ ├── Util.java │ ├── evaluation │ │ ├── Evaluation0.java │ │ ├── Evaluation1.java │ │ ├── Evaluation10.java │ │ ├── Evaluation100.java │ │ ├── Evaluation101.java │ │ ├── Evaluation102.java │ │ ├── Evaluation103.java │ │ ├── Evaluation104.java │ │ ├── Evaluation105.java │ │ ├── Evaluation106.java │ │ ├── Evaluation107.java │ │ ├── Evaluation108.java │ │ ├── Evaluation109.java │ │ ├── Evaluation11.java │ │ ├── Evaluation110.java │ │ ├── Evaluation111.java │ │ ├── Evaluation112.java │ │ ├── Evaluation113.java │ │ ├── Evaluation114.java │ │ ├── Evaluation115.java │ │ ├── Evaluation116.java │ │ ├── Evaluation117.java │ │ ├── Evaluation118.java │ │ ├── Evaluation119.java │ │ ├── Evaluation12.java │ │ ├── Evaluation120.java │ │ ├── Evaluation121.java │ │ ├── Evaluation122.java │ │ ├── Evaluation123.java │ │ ├── Evaluation124.java │ │ ├── Evaluation125.java │ │ ├── Evaluation126.java │ │ ├── Evaluation127.java │ │ ├── Evaluation128.java │ │ ├── Evaluation129.java │ │ ├── Evaluation13.java │ │ ├── Evaluation130.java │ │ ├── Evaluation131.java │ │ ├── Evaluation132.java │ │ ├── Evaluation133.java │ │ ├── Evaluation134.java │ │ ├── Evaluation135.java │ │ ├── Evaluation136.java │ │ ├── Evaluation137.java │ │ ├── Evaluation138.java │ │ ├── Evaluation139.java │ │ ├── Evaluation14.java │ │ ├── Evaluation140.java │ │ ├── Evaluation141.java │ │ ├── Evaluation142.java │ │ ├── Evaluation143.java │ │ ├── Evaluation144.java │ │ ├── Evaluation145.java │ │ ├── Evaluation146.java │ │ ├── Evaluation147.java │ │ ├── Evaluation148.java │ │ ├── Evaluation149.java │ │ ├── Evaluation15.java │ │ ├── Evaluation151.java │ │ ├── Evaluation152.java │ │ ├── Evaluation153.java │ │ ├── Evaluation154.java │ │ ├── Evaluation156.java │ │ ├── Evaluation157.java │ │ ├── Evaluation16.java │ │ ├── Evaluation160.java │ │ ├── Evaluation161.java │ │ ├── Evaluation162.java │ │ ├── Evaluation163.java │ │ ├── Evaluation164.java │ │ ├── Evaluation165.java │ │ ├── Evaluation166.java │ │ ├── Evaluation167.java │ │ ├── Evaluation168.java │ │ ├── Evaluation169.java │ │ ├── Evaluation17.java │ │ ├── Evaluation170.java │ │ ├── Evaluation171.java │ │ ├── Evaluation172.java │ │ ├── Evaluation173.java │ │ ├── Evaluation174.java │ │ ├── Evaluation176.java │ │ ├── Evaluation177.java │ │ ├── Evaluation178.java │ │ ├── Evaluation179.java │ │ ├── Evaluation18.java │ │ ├── Evaluation180.java │ │ ├── Evaluation181.java │ │ ├── Evaluation182.java │ │ ├── Evaluation183.java │ │ ├── Evaluation186.java │ │ ├── Evaluation19.java │ │ ├── Evaluation2.java │ │ ├── Evaluation20.java │ │ ├── Evaluation21.java │ │ ├── Evaluation22.java │ │ ├── Evaluation23.java │ │ ├── Evaluation24.java │ │ ├── Evaluation25.java │ │ ├── Evaluation26.java │ │ ├── Evaluation27.java │ │ ├── Evaluation28.java │ │ ├── Evaluation29.java │ │ ├── Evaluation3.java │ │ ├── Evaluation30.java │ │ ├── Evaluation31.java │ │ ├── Evaluation32.java │ │ ├── Evaluation33.java │ │ ├── Evaluation34.java │ │ ├── Evaluation35.java │ │ ├── Evaluation36.java │ │ ├── Evaluation37.java │ │ ├── Evaluation38.java │ │ ├── Evaluation39.java │ │ ├── Evaluation4.java │ │ ├── Evaluation40.java │ │ ├── Evaluation41.java │ │ ├── Evaluation42.java │ │ ├── Evaluation43.java │ │ ├── Evaluation44.java │ │ ├── Evaluation45.java │ │ ├── Evaluation46.java │ │ ├── Evaluation47.java │ │ ├── Evaluation48.java │ │ ├── Evaluation49.java │ │ ├── Evaluation5.java │ │ ├── Evaluation50.java │ │ ├── Evaluation51.java │ │ ├── Evaluation52.java │ │ ├── Evaluation53.java │ │ ├── Evaluation55.java │ │ ├── Evaluation56.java │ │ ├── Evaluation57.java │ │ ├── Evaluation58.java │ │ ├── Evaluation6.java │ │ ├── Evaluation60.java │ │ ├── Evaluation62.java │ │ ├── Evaluation63.java │ │ ├── Evaluation64.java │ │ ├── Evaluation65.java │ │ ├── Evaluation66.java │ │ ├── Evaluation67.java │ │ ├── Evaluation68.java │ │ ├── Evaluation69.java │ │ ├── Evaluation7.java │ │ ├── Evaluation70.java │ │ ├── Evaluation71.java │ │ ├── Evaluation72.java │ │ ├── Evaluation73.java │ │ ├── Evaluation75.java │ │ ├── Evaluation76.java │ │ ├── Evaluation78.java │ │ ├── Evaluation79.java │ │ ├── Evaluation8.java │ │ ├── Evaluation80.java │ │ ├── Evaluation81.java │ │ ├── Evaluation82.java │ │ ├── Evaluation83.java │ │ ├── Evaluation84.java │ │ ├── Evaluation85.java │ │ ├── Evaluation86.java │ │ ├── Evaluation87.java │ │ ├── Evaluation88.java │ │ ├── Evaluation89.java │ │ ├── Evaluation9.java │ │ ├── Evaluation90.java │ │ ├── Evaluation91.java │ │ ├── Evaluation92.java │ │ ├── Evaluation93.java │ │ ├── Evaluation94.java │ │ ├── Evaluation95.java │ │ ├── Evaluation96.java │ │ ├── Evaluation97.java │ │ ├── Evaluation98.java │ │ └── Evaluation99.java │ ├── generate │ │ ├── aixcoder │ │ │ ├── AixcoderOld0.java │ │ │ ├── AixcoderOld1.java │ │ │ ├── AixcoderOld10.java │ │ │ ├── AixcoderOld100.java │ │ │ ├── AixcoderOld101.java │ │ │ ├── AixcoderOld102.java │ │ │ ├── AixcoderOld103.java │ │ │ ├── AixcoderOld104.java │ │ │ ├── AixcoderOld105.java │ │ │ ├── AixcoderOld106.java │ │ │ ├── AixcoderOld107.java │ │ │ ├── AixcoderOld108.java │ │ │ ├── AixcoderOld109.java │ │ │ ├── AixcoderOld11.java │ │ │ ├── AixcoderOld110.java │ │ │ ├── AixcoderOld111.java │ │ │ ├── AixcoderOld112.java │ │ │ ├── AixcoderOld113.java │ │ │ ├── AixcoderOld114.java │ │ │ ├── AixcoderOld115.java │ │ │ ├── AixcoderOld116.java │ │ │ ├── AixcoderOld117.java │ │ │ ├── AixcoderOld118.java │ │ │ ├── AixcoderOld119.java │ │ │ ├── AixcoderOld12.java │ │ │ ├── AixcoderOld120.java │ │ │ ├── AixcoderOld121.java │ │ │ ├── AixcoderOld122.java │ │ │ ├── AixcoderOld123.java │ │ │ ├── AixcoderOld124.java │ │ │ ├── AixcoderOld125.java │ │ │ ├── AixcoderOld126.java │ │ │ ├── AixcoderOld127.java │ │ │ ├── AixcoderOld128.java │ │ │ ├── AixcoderOld129.java │ │ │ ├── AixcoderOld13.java │ │ │ ├── AixcoderOld130.java │ │ │ ├── AixcoderOld131.java │ │ │ ├── AixcoderOld132.java │ │ │ ├── AixcoderOld133.java │ │ │ ├── AixcoderOld134.java │ │ │ ├── AixcoderOld135.java │ │ │ ├── AixcoderOld136.java │ │ │ ├── AixcoderOld137.java │ │ │ ├── AixcoderOld138.java │ │ │ ├── AixcoderOld139.java │ │ │ ├── AixcoderOld14.java │ │ │ ├── AixcoderOld140.java │ │ │ ├── AixcoderOld141.java │ │ │ ├── AixcoderOld142.java │ │ │ ├── AixcoderOld143.java │ │ │ ├── AixcoderOld144.java │ │ │ ├── AixcoderOld145.java │ │ │ ├── AixcoderOld146.java │ │ │ ├── AixcoderOld147.java │ │ │ ├── AixcoderOld148.java │ │ │ ├── AixcoderOld149.java │ │ │ ├── AixcoderOld15.java │ │ │ ├── AixcoderOld151.java │ │ │ ├── AixcoderOld152.java │ │ │ ├── AixcoderOld153.java │ │ │ ├── AixcoderOld154.java │ │ │ ├── AixcoderOld156.java │ │ │ ├── AixcoderOld157.java │ │ │ ├── AixcoderOld16.java │ │ │ ├── AixcoderOld160.java │ │ │ ├── AixcoderOld161.java │ │ │ ├── AixcoderOld162.java │ │ │ ├── AixcoderOld163.java │ │ │ ├── AixcoderOld164.java │ │ │ ├── AixcoderOld165.java │ │ │ ├── AixcoderOld166.java │ │ │ ├── AixcoderOld167.java │ │ │ ├── AixcoderOld168.java │ │ │ ├── AixcoderOld169.java │ │ │ ├── AixcoderOld17.java │ │ │ ├── AixcoderOld170.java │ │ │ ├── AixcoderOld171.java │ │ │ ├── AixcoderOld172.java │ │ │ ├── AixcoderOld173.java │ │ │ ├── AixcoderOld174.java │ │ │ ├── AixcoderOld176.java │ │ │ ├── AixcoderOld177.java │ │ │ ├── AixcoderOld178.java │ │ │ ├── AixcoderOld179.java │ │ │ ├── AixcoderOld18.java │ │ │ ├── AixcoderOld180.java │ │ │ ├── AixcoderOld181.java │ │ │ ├── AixcoderOld182.java │ │ │ ├── AixcoderOld183.java │ │ │ ├── AixcoderOld186.java │ │ │ ├── AixcoderOld19.java │ │ │ ├── AixcoderOld2.java │ │ │ ├── AixcoderOld20.java │ │ │ ├── AixcoderOld21.java │ │ │ ├── AixcoderOld22.java │ │ │ ├── AixcoderOld23.java │ │ │ ├── AixcoderOld24.java │ │ │ ├── AixcoderOld25.java │ │ │ ├── AixcoderOld26.java │ │ │ ├── AixcoderOld27.java │ │ │ ├── AixcoderOld28.java │ │ │ ├── AixcoderOld29.java │ │ │ ├── AixcoderOld3.java │ │ │ ├── AixcoderOld30.java │ │ │ ├── AixcoderOld31.java │ │ │ ├── AixcoderOld32.java │ │ │ ├── AixcoderOld33.java │ │ │ ├── AixcoderOld34.java │ │ │ ├── AixcoderOld35.java │ │ │ ├── AixcoderOld36.java │ │ │ ├── AixcoderOld37.java │ │ │ ├── AixcoderOld38.java │ │ │ ├── AixcoderOld39.java │ │ │ ├── AixcoderOld4.java │ │ │ ├── AixcoderOld40.java │ │ │ ├── AixcoderOld41.java │ │ │ ├── AixcoderOld42.java │ │ │ ├── AixcoderOld43.java │ │ │ ├── AixcoderOld44.java │ │ │ ├── AixcoderOld45.java │ │ │ ├── AixcoderOld46.java │ │ │ ├── AixcoderOld47.java │ │ │ ├── AixcoderOld48.java │ │ │ ├── AixcoderOld49.java │ │ │ ├── AixcoderOld5.java │ │ │ ├── AixcoderOld50.java │ │ │ ├── AixcoderOld51.java │ │ │ ├── AixcoderOld52.java │ │ │ ├── AixcoderOld53.java │ │ │ ├── AixcoderOld55.java │ │ │ ├── AixcoderOld56.java │ │ │ ├── AixcoderOld57.java │ │ │ ├── AixcoderOld58.java │ │ │ ├── AixcoderOld6.java │ │ │ ├── AixcoderOld60.java │ │ │ ├── AixcoderOld62.java │ │ │ ├── AixcoderOld63.java │ │ │ ├── AixcoderOld64.java │ │ │ ├── AixcoderOld65.java │ │ │ ├── AixcoderOld66.java │ │ │ ├── AixcoderOld67.java │ │ │ ├── AixcoderOld68.java │ │ │ ├── AixcoderOld69.java │ │ │ ├── AixcoderOld7.java │ │ │ ├── AixcoderOld70.java │ │ │ ├── AixcoderOld71.java │ │ │ ├── AixcoderOld72.java │ │ │ ├── AixcoderOld73.java │ │ │ ├── AixcoderOld75.java │ │ │ ├── AixcoderOld76.java │ │ │ ├── AixcoderOld78.java │ │ │ ├── AixcoderOld79.java │ │ │ ├── AixcoderOld8.java │ │ │ ├── AixcoderOld80.java │ │ │ ├── AixcoderOld81.java │ │ │ ├── AixcoderOld82.java │ │ │ ├── AixcoderOld83.java │ │ │ ├── AixcoderOld84.java │ │ │ ├── AixcoderOld85.java │ │ │ ├── AixcoderOld86.java │ │ │ ├── AixcoderOld87.java │ │ │ ├── AixcoderOld88.java │ │ │ ├── AixcoderOld89.java │ │ │ ├── AixcoderOld9.java │ │ │ ├── AixcoderOld90.java │ │ │ ├── AixcoderOld91.java │ │ │ ├── AixcoderOld92.java │ │ │ ├── AixcoderOld93.java │ │ │ ├── AixcoderOld94.java │ │ │ ├── AixcoderOld95.java │ │ │ ├── AixcoderOld96.java │ │ │ ├── AixcoderOld97.java │ │ │ ├── AixcoderOld98.java │ │ │ └── AixcoderOld99.java │ │ └── copilot │ │ │ ├── GenerateMethod0.java │ │ │ ├── GenerateMethod1.java │ │ │ ├── GenerateMethod10.java │ │ │ ├── GenerateMethod100.java │ │ │ ├── GenerateMethod101.java │ │ │ ├── GenerateMethod102.java │ │ │ ├── GenerateMethod103.java │ │ │ ├── GenerateMethod104.java │ │ │ ├── GenerateMethod105.java │ │ │ ├── GenerateMethod106.java │ │ │ ├── GenerateMethod107.java │ │ │ ├── GenerateMethod108.java │ │ │ ├── GenerateMethod109.java │ │ │ ├── GenerateMethod11.java │ │ │ ├── GenerateMethod110.java │ │ │ ├── GenerateMethod111.java │ │ │ ├── GenerateMethod112.java │ │ │ ├── GenerateMethod113.java │ │ │ ├── GenerateMethod114.java │ │ │ ├── GenerateMethod115.java │ │ │ ├── GenerateMethod116.java │ │ │ ├── GenerateMethod117.java │ │ │ ├── GenerateMethod118.java │ │ │ ├── GenerateMethod119.java │ │ │ ├── GenerateMethod12.java │ │ │ ├── GenerateMethod120.java │ │ │ ├── GenerateMethod121.java │ │ │ ├── GenerateMethod122.java │ │ │ ├── GenerateMethod123.java │ │ │ ├── GenerateMethod124.java │ │ │ ├── GenerateMethod125.java │ │ │ ├── GenerateMethod126.java │ │ │ ├── GenerateMethod127.java │ │ │ ├── GenerateMethod128.java │ │ │ ├── GenerateMethod129.java │ │ │ ├── GenerateMethod13.java │ │ │ ├── GenerateMethod130.java │ │ │ ├── GenerateMethod131.java │ │ │ ├── GenerateMethod132.java │ │ │ ├── GenerateMethod133.java │ │ │ ├── GenerateMethod134.java │ │ │ ├── GenerateMethod135.java │ │ │ ├── GenerateMethod136.java │ │ │ ├── GenerateMethod137.java │ │ │ ├── GenerateMethod138.java │ │ │ ├── GenerateMethod139.java │ │ │ ├── GenerateMethod14.java │ │ │ ├── GenerateMethod140.java │ │ │ ├── GenerateMethod141.java │ │ │ ├── GenerateMethod142.java │ │ │ ├── GenerateMethod143.java │ │ │ ├── GenerateMethod144.java │ │ │ ├── GenerateMethod145.java │ │ │ ├── GenerateMethod146.java │ │ │ ├── GenerateMethod147.java │ │ │ ├── GenerateMethod148.java │ │ │ ├── GenerateMethod149.java │ │ │ ├── GenerateMethod15.java │ │ │ ├── GenerateMethod151.java │ │ │ ├── GenerateMethod152.java │ │ │ ├── GenerateMethod153.java │ │ │ ├── GenerateMethod154.java │ │ │ ├── GenerateMethod156.java │ │ │ ├── GenerateMethod157.java │ │ │ ├── GenerateMethod16.java │ │ │ ├── GenerateMethod160.java │ │ │ ├── GenerateMethod161.java │ │ │ ├── GenerateMethod162.java │ │ │ ├── GenerateMethod163.java │ │ │ ├── GenerateMethod164.java │ │ │ ├── GenerateMethod165.java │ │ │ ├── GenerateMethod166.java │ │ │ ├── GenerateMethod167.java │ │ │ ├── GenerateMethod168.java │ │ │ ├── GenerateMethod169.java │ │ │ ├── GenerateMethod17.java │ │ │ ├── GenerateMethod170.java │ │ │ ├── GenerateMethod171.java │ │ │ ├── GenerateMethod172.java │ │ │ ├── GenerateMethod173.java │ │ │ ├── GenerateMethod174.java │ │ │ ├── GenerateMethod176.java │ │ │ ├── GenerateMethod177.java │ │ │ ├── GenerateMethod178.java │ │ │ ├── GenerateMethod179.java │ │ │ ├── GenerateMethod18.java │ │ │ ├── GenerateMethod180.java │ │ │ ├── GenerateMethod181.java │ │ │ ├── GenerateMethod182.java │ │ │ ├── GenerateMethod183.java │ │ │ ├── GenerateMethod186.java │ │ │ ├── GenerateMethod19.java │ │ │ ├── GenerateMethod2.java │ │ │ ├── GenerateMethod20.java │ │ │ ├── GenerateMethod21.java │ │ │ ├── GenerateMethod22.java │ │ │ ├── GenerateMethod23.java │ │ │ ├── GenerateMethod24.java │ │ │ ├── GenerateMethod25.java │ │ │ ├── GenerateMethod26.java │ │ │ ├── GenerateMethod27.java │ │ │ ├── GenerateMethod28.java │ │ │ ├── GenerateMethod29.java │ │ │ ├── GenerateMethod3.java │ │ │ ├── GenerateMethod30.java │ │ │ ├── GenerateMethod31.java │ │ │ ├── GenerateMethod32.java │ │ │ ├── GenerateMethod33.java │ │ │ ├── GenerateMethod34.java │ │ │ ├── GenerateMethod35.java │ │ │ ├── GenerateMethod36.java │ │ │ ├── GenerateMethod37.java │ │ │ ├── GenerateMethod38.java │ │ │ ├── GenerateMethod39.java │ │ │ ├── GenerateMethod4.java │ │ │ ├── GenerateMethod40.java │ │ │ ├── GenerateMethod41.java │ │ │ ├── GenerateMethod42.java │ │ │ ├── GenerateMethod43.java │ │ │ ├── GenerateMethod44.java │ │ │ ├── GenerateMethod45.java │ │ │ ├── GenerateMethod46.java │ │ │ ├── GenerateMethod47.java │ │ │ ├── GenerateMethod48.java │ │ │ ├── GenerateMethod49.java │ │ │ ├── GenerateMethod5.java │ │ │ ├── GenerateMethod50.java │ │ │ ├── GenerateMethod51.java │ │ │ ├── GenerateMethod52.java │ │ │ ├── GenerateMethod53.java │ │ │ ├── GenerateMethod55.java │ │ │ ├── GenerateMethod56.java │ │ │ ├── GenerateMethod57.java │ │ │ ├── GenerateMethod58.java │ │ │ ├── GenerateMethod6.java │ │ │ ├── GenerateMethod60.java │ │ │ ├── GenerateMethod62.java │ │ │ ├── GenerateMethod63.java │ │ │ ├── GenerateMethod64.java │ │ │ ├── GenerateMethod65.java │ │ │ ├── GenerateMethod66.java │ │ │ ├── GenerateMethod67.java │ │ │ ├── GenerateMethod68.java │ │ │ ├── GenerateMethod69.java │ │ │ ├── GenerateMethod7.java │ │ │ ├── GenerateMethod70.java │ │ │ ├── GenerateMethod71.java │ │ │ ├── GenerateMethod72.java │ │ │ ├── GenerateMethod73.java │ │ │ ├── GenerateMethod75.java │ │ │ ├── GenerateMethod76.java │ │ │ ├── GenerateMethod78.java │ │ │ ├── GenerateMethod79.java │ │ │ ├── GenerateMethod8.java │ │ │ ├── GenerateMethod80.java │ │ │ ├── GenerateMethod81.java │ │ │ ├── GenerateMethod82.java │ │ │ ├── GenerateMethod83.java │ │ │ ├── GenerateMethod84.java │ │ │ ├── GenerateMethod85.java │ │ │ ├── GenerateMethod86.java │ │ │ ├── GenerateMethod87.java │ │ │ ├── GenerateMethod88.java │ │ │ ├── GenerateMethod89.java │ │ │ ├── GenerateMethod9.java │ │ │ ├── GenerateMethod90.java │ │ │ ├── GenerateMethod91.java │ │ │ ├── GenerateMethod92.java │ │ │ ├── GenerateMethod93.java │ │ │ ├── GenerateMethod94.java │ │ │ ├── GenerateMethod95.java │ │ │ ├── GenerateMethod96.java │ │ │ ├── GenerateMethod97.java │ │ │ ├── GenerateMethod98.java │ │ │ └── GenerateMethod99.java │ └── predictionHelper.java │ └── sampleHelper │ ├── Male.java │ ├── Person.java │ ├── Student.java │ └── sample27 │ ├── InterfaceWithAnnotation.java │ └── TestFor27.java └── resources ├── dataset_autotest_nl.jsonl ├── dataset_manual_nl.jsonl ├── prediction.jsonl └── tempFile ├── copyFile.txt ├── sample173.txt ├── tempFile116.txt ├── test144 ├── data144.zip └── data144.zip.bak ├── test163 └── srcDir │ └── dir1 │ └── dir2 │ └── file1.tmp ├── test76 ├── test1 │ └── BaseAbstractTest.class └── test2 │ ├── 2 │ └── Constants.class │ └── BaseAbstractTest.class └── test81 └── fromDir └── file1.tmp /.gitignore: -------------------------------------------------------------------------------- 1 | /out/ 2 | /.idea/ 3 | /HumanTest.iml 4 | /.DS_Store 5 | /src/com/.DS_Store 6 | /src/main/com/aixcode/resource/tempFile/*.tmp 7 | /src/main/com/aixcode/resource/localFile/** 8 | /**/.DS_Store 9 | /*.zip 10 | /*.iml 11 | /src/main/com/** 12 | /src/main/java/com/aixcode/autoTest/version1/** 13 | /src/main/java/com/aixcode/autoTest/aixcoderV3/** 14 | /src/main/java/com/aixcode/autoTest/aixcoderV2/** 15 | -------------------------------------------------------------------------------- /lib/gson-2.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/lib/gson-2.9.0.jar -------------------------------------------------------------------------------- /lib/jackson-annotations-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/lib/jackson-annotations-2.13.3.jar -------------------------------------------------------------------------------- /lib/jackson-core-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/lib/jackson-core-2.13.3.jar -------------------------------------------------------------------------------- /lib/jackson-databind-2.13.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/lib/jackson-databind-2.13.3.jar -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/Util.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class Util { 8 | public static List listFiles(String path) { 9 | File file = new File(path); 10 | List res = new ArrayList(); 11 | File[] files = file.listFiles(); 12 | for (int i = 0; i < files.length; i++) { 13 | if (!files[i].isDirectory()) 14 | res.add(files[i].getName()); 15 | } 16 | return res; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/evaluation/Evaluation181.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.evaluation; 2 | 3 | 4 | 5 | import com.aixcode.autoTest.AbstractBaseEvaluation; 6 | import com.aixcode.sampleHelper.Male; 7 | 8 | import java.util.List; 9 | 10 | public class Evaluation181 extends AbstractBaseEvaluation { 11 | public Evaluation181(String basePackage, String prefix) { 12 | super(basePackage, prefix); 13 | } 14 | 15 | @Override 16 | public int[] evaluation() { 17 | int passCount = 0; 18 | try { 19 | List list=solution.getClassGenricType(Male.class); 20 | if (list!=null&&list.size()==2&&list.contains(String.class)&&list.contains(Integer.class)){ 21 | passCount++; 22 | } 23 | }catch (Exception e){ 24 | 25 | } 26 | return new int[]{passCount,1}; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/evaluation/Evaluation22.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.evaluation; 2 | 3 | import com.aixcode.autoTest.AbstractBaseEvaluation; 4 | 5 | 6 | public class Evaluation22 extends AbstractBaseEvaluation { 7 | 8 | 9 | public Evaluation22(String basePackage, String prefix) { 10 | super(basePackage, prefix); 11 | } 12 | 13 | @Override 14 | public int[] evaluation() { 15 | int pass_cunt = 0 ; 16 | try { 17 | String date = solution.readImageData("autoTest.png"); 18 | if (null != date && date.length() > 0){ 19 | pass_cunt ++; 20 | } 21 | }catch (Exception e) { 22 | 23 | } 24 | return new int[] {pass_cunt,1}; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/evaluation/Evaluation4.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.evaluation; 2 | 3 | import com.aixcode.autoTest.AbstractBaseEvaluation; 4 | 5 | import java.io.Reader; 6 | import java.io.StringReader; 7 | 8 | public class Evaluation4 extends AbstractBaseEvaluation { 9 | 10 | 11 | public Evaluation4(String basePackage, String prefix) { 12 | super(basePackage, prefix); 13 | } 14 | 15 | @Override 16 | public int[] evaluation() { 17 | Reader reader = new StringReader("abc"); 18 | int pass_count = 0; 19 | try { 20 | solution.close(reader); 21 | try { 22 | reader.read(); 23 | }catch (Exception e) { 24 | pass_count++; 25 | } 26 | }catch (Exception e) { 27 | 28 | } 29 | return new int[]{pass_count,1}; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld0.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Iterator; 6 | import java.util.List; 7 | 8 | public class AixcoderOld0 extends GenerateMethodBase { 9 | public String collectionToCommaDelimitedString(List coll) 10 | { 11 | StringBuilder sb = new StringBuilder ( ) ; 12 | for (Iterator< String > it = coll . iterator ( ); it . hasNext ( ) ; ) { 13 | sb . append ( it . next ( ) ) ; 14 | if ( it . hasNext ( ) ) { 15 | sb . append ( ", " ) ; 16 | } 17 | } 18 | return sb . toString ( ) ; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld1.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld1 extends GenerateMethodBase { 5 | public String createPadding(int length, char padChar) 6 | { 7 | StringBuffer sb = new StringBuffer ( ) ; 8 | for ( int i = 0 ; i < length ; i ++ ) { 9 | sb . append ( padChar ) ; 10 | } 11 | return sb . toString ( ) ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld10.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class AixcoderOld10 extends GenerateMethodBase { 10 | public List getBackupFiles(String dir) 11 | { 12 | List < String > list = new ArrayList< String >( ) ; 13 | File[ ] files = new File ( dir ) . listFiles ( ) ; 14 | if ( files != null ) { 15 | for ( File file : files ) { 16 | if ( file . getName ( ) . endsWith ( ".json" ) ) { 17 | list . add ( file . getName ( ) ) ; 18 | } 19 | } 20 | } 21 | return list ; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld100.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.nio.charset.Charset; 6 | import java.nio.charset.IllegalCharsetNameException; 7 | import java.nio.charset.UnsupportedCharsetException; 8 | 9 | public class AixcoderOld100 extends GenerateMethodBase { 10 | public String canonicalEncodingName(String encoding) 11 | { 12 | if ( encoding == null ) { 13 | return null ; 14 | } 15 | try { 16 | return Charset. forName ( encoding ) . name ( ) ; 17 | } catch ( IllegalCharsetNameException icne ) { 18 | return encoding ; 19 | } catch ( UnsupportedCharsetException uce ) { 20 | return encoding ; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld101.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld101 extends GenerateMethodBase { 5 | public int[] copy(int[] arr) 6 | { 7 | if ( arr == null ) { 8 | return null ; 9 | } 10 | int [ ] copy = new int [ arr . length ] ; 11 | System . arraycopy ( arr , 0 , copy , 0 , arr . length ) ; 12 | return copy ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld102.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class AixcoderOld102 extends GenerateMethodBase { 8 | public int size(Map map) 9 | { 10 | int result = 0 ; 11 | if ( map != null ) { 12 | result = map . size ( ) ; 13 | } 14 | return result ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld103.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld103 extends GenerateMethodBase { 5 | public boolean equals(double a, double b, double epsilon) 6 | { 7 | if ( a == b ) 8 | return true ; 9 | else if ( Math . abs ( a - b ) < epsilon ) 10 | return true ; 11 | else 12 | return false ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld104.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld104 extends GenerateMethodBase { 5 | public void putShort(byte[] data, byte b, short s) 6 | { 7 | int length = data . length ; 8 | //if ( length + 2 > data . length ) { 9 | //enlarge ( 2 ) ; 10 | //} 11 | data [ length ++ ] = b ; 12 | data [ length ++ ] = ( byte ) ( s >>> 8 ) ; 13 | data [ length ] = ( byte ) s ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld105.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Iterator; 6 | 7 | public class AixcoderOld105 extends GenerateMethodBase { 8 | public int next(Iterator iterator, int n) 9 | { 10 | int result = 0 ; 11 | while ( n > 0 && iterator . hasNext ( ) ) { 12 | result = iterator . next ( ) ; 13 | -- n ; 14 | } 15 | while ( iterator . hasNext ( ) ) { 16 | iterator . next ( ) ; 17 | ++ n ; 18 | } 19 | return result ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld106.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld106 extends GenerateMethodBase { 6 | public int[][] arrayToMatrix(int[] m, int width, int height) { 7 | int[][] result = new int[height][width]; 8 | for (int i = 0; i < height; i++) { 9 | for (int j = 0; j < width; j++) { 10 | int p = j * height + i; 11 | result[i][j] = m[p]; 12 | } 13 | } 14 | return result; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld107.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld107 extends GenerateMethodBase { 5 | public boolean checkNotNullOrEmpty(int[] array) 6 | { 7 | if (array == null) { 8 | return false; 9 | } 10 | return array.length != 0; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld108.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld108 extends GenerateMethodBase { 6 | public String removeAllWhiteSpaces(String str) { 7 | if (str == "") { 8 | return ""; 9 | } 10 | StringBuilder sb = new StringBuilder(str); 11 | int sz = sb.length(); 12 | char c; 13 | for (int i = 0; i < sz; i++) { 14 | c = sb.charAt(i); 15 | if (!Character.isWhitespace(c)) { 16 | sb.setCharAt(i, ' '); 17 | } 18 | } 19 | return sb.toString(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld109.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld109 extends GenerateMethodBase { 5 | public String[] sub(String[] a, String[] b) 6 | { 7 | String [ ] c = new String [ a . length ] ; 8 | for ( int i = 0 ; i < a . length ; i ++ ) { 9 | //c [ i ] = sub ( a [ i ] , b [ i ] ) ; 10 | } 11 | return c ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld11.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Random; 6 | 7 | public class AixcoderOld11 extends GenerateMethodBase { 8 | public void shuffle(int[] array) 9 | { 10 | if ( array == null ) 11 | throw new NullPointerException ( "argument array is null" ) ; 12 | int n = array . length ; 13 | for ( int i = 0 ; i < n ; i ++ ) { 14 | // between i and n-1 15 | int r = i + new Random().nextInt( n - i ) ; 16 | int temp = array [ i ] ; 17 | array [ i ] = array [ r ] ; 18 | array [ r ] = temp ; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld110.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld110 extends GenerateMethodBase { 5 | public float parseFloat(String floatStr) 6 | { 7 | if ( floatStr == null ) 8 | return -1 ; 9 | return new Float ( floatStr ) . floatValue ( ) ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld111.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | 6 | public class AixcoderOld111 extends GenerateMethodBase { 7 | public boolean isWindowsAbsolutePath(String path) 8 | { 9 | //if ( ! isAbsolutePath ( path ) ) 10 | //return false ; 11 | // On Windows, an absolute path starts with "[drive_letter]:\". 12 | if ( path . length ( ) > 2 && path . charAt ( 1 ) == ':' && Character . isLetter ( path . charAt ( 0 ) ) && ( path . charAt ( 2 ) == '\\' || path . charAt ( 2 ) == '/' ) ) 13 | return true ; 14 | else 15 | return false ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld112.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld112 extends GenerateMethodBase { 5 | public double length(double[] p0, double[] p1) 6 | { 7 | double sum = 0 ; 8 | for ( int i = 0 ; i < p0 . length ; i ++ ) { 9 | double d = p0 [ i ] - p1 [ i ] ; 10 | sum += d * d ; 11 | } 12 | return Math . sqrt ( sum ) ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld113.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld113 extends GenerateMethodBase { 5 | public String getStringfromStringArray(String[] array) 6 | { 7 | String s = "" ; 8 | if ( array == null ) { 9 | return s ; 10 | } 11 | for ( int i = 0 ; i < array . length ; i ++ ) { 12 | s += array [ i ] + " " ; 13 | } 14 | return s ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld114.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.util.zip.ZipFile; 8 | 9 | public class AixcoderOld114 extends GenerateMethodBase { 10 | public boolean isValidZip(File zip) 11 | { 12 | ZipFile zipFile = null ; 13 | try { 14 | zipFile = new ZipFile ( zip ) ; 15 | } catch ( IOException e ) { 16 | return false ; 17 | } finally { 18 | if ( zipFile != null ) { 19 | try { 20 | zipFile . close ( ) ; 21 | } catch ( IOException e ) { 22 | // ignore 23 | } 24 | } 25 | } 26 | return true ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld115.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld115 extends GenerateMethodBase { 5 | public String[] toTimestampStrs(long[] timestamps) 6 | { 7 | if ( timestamps == null ) { 8 | return null ; 9 | } 10 | String [ ] result = new String [ timestamps . length ] ; 11 | for ( int i = 0 ; i < timestamps . length ; ++ i ) { 12 | result [ i ] = Long . toString ( timestamps [ i ] ) ; 13 | } 14 | return result ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld116.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld116 extends GenerateMethodBase { 6 | public int[] resize(int[] arr, long newSize) { 7 | int[] newArr = new int[(int) newSize]; 8 | 9 | if (arr != null) { 10 | System.arraycopy(arr, 0, newArr, 0, Math.min(arr.length, (int) newSize)); 11 | } 12 | 13 | return newArr; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld117.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld117 extends GenerateMethodBase { 5 | public byte[] subBytes(byte[] src, int pos, int count) 6 | { 7 | byte [ ] dest = new byte [ count ] ; 8 | System . arraycopy ( src , pos , dest , 0 , count ) ; 9 | return dest ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld118.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld118 extends GenerateMethodBase { 5 | public int floor(double val) 6 | { 7 | int i = ( int ) val ; 8 | return val < i ? i -1 : i ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld119.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.DecimalFormat; 6 | 7 | public class AixcoderOld119 extends GenerateMethodBase { 8 | public String formatDouble(double val) 9 | { 10 | DecimalFormat df = new DecimalFormat ( "#.00" ) ; 11 | return df . format ( val ) ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld12.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class AixcoderOld12 extends GenerateMethodBase { 8 | public String getValue(List list, int index) 9 | { 10 | if ( list == null || index < 0 || index >= list . size ( ) ) { 11 | return null ; 12 | } 13 | return list . get ( index ) ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld120.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld120 extends GenerateMethodBase { 5 | public int compare(double double1, double double2) 6 | { 7 | if ( double1 < double2 ) { 8 | return -1 ; 9 | } 10 | if ( double1 > double2 ) { 11 | return 1 ; 12 | } 13 | return 0 ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld121.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld121 extends GenerateMethodBase { 5 | public int getNextSlash(String path, int index) 6 | { 7 | int nextSlash = path . indexOf ( '/' , index + 1 ) ; 8 | if ( nextSlash == -1 || nextSlash == path . length ( ) -1 ) { 9 | return -1 ; 10 | } 11 | return nextSlash ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld122.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld122 extends GenerateMethodBase { 5 | public boolean isNonNegative(long[][] in) 6 | { 7 | for ( int i = 0 ; i < in . length ; i ++ ) { 8 | for ( int j = 0 ; j < in [ i ] . length ; j ++ ) { 9 | if ( in [ i ] [ j ] < 0 ) { 10 | return false ; 11 | } 12 | } 13 | } 14 | return true ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld123.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld123 extends GenerateMethodBase { 5 | public int floor(int x, int quantum) 6 | { 7 | int i = x / quantum ; 8 | return x - ( i * quantum ) ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld124.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class AixcoderOld124 extends GenerateMethodBase { 9 | public void append(List list, String item) { 10 | if (list == null) 11 | list = new ArrayList(); 12 | list.add(item); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld125.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | 8 | 9 | public class AixcoderOld125 extends GenerateMethodBase { 10 | public int getDaysByMonth(String dateTime) 11 | { 12 | Calendar cal = Calendar . getInstance ( ) ; 13 | //cal . setTime ( parse ( dateTime ) ) ; 14 | return cal . getActualMaximum ( Calendar . DAY_OF_MONTH ) ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld127.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld127 extends GenerateMethodBase { 6 | public int[] range(int start, int end) { 7 | int[] a = new int[end - start + 1]; 8 | for (int i = start; i <= end; i++) { 9 | a[i - start] = i; 10 | } 11 | return a; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld129.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Calendar; 7 | 8 | public class AixcoderOld129 extends GenerateMethodBase { 9 | public String getNowDate(int minute) 10 | { 11 | SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; 12 | Calendar calendar = Calendar . getInstance ( ) ; 13 | calendar . add ( Calendar . MINUTE , minute ) ; 14 | return sdf . format ( calendar . getTime ( ) ) ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld13.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Random; 6 | 7 | public class AixcoderOld13 extends GenerateMethodBase { 8 | public String randomString(int length, String alphabet) 9 | { 10 | if ( alphabet == null ) { 11 | return null ; 12 | } 13 | StringBuilder sb = new StringBuilder ( length ) ; 14 | for ( int i = 0 ; i < length ; i ++ ) { 15 | sb . append ( alphabet . charAt ( new Random().nextInt( alphabet . length ( ) ) ) ) ; 16 | } 17 | return sb . toString ( ) ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld130.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.math.BigDecimal; 6 | 7 | public class AixcoderOld130 extends GenerateMethodBase { 8 | public boolean isDecimalWithinIntRange(BigDecimal decimalValue) 9 | { 10 | if ( decimalValue == null ) { 11 | return false ; 12 | } 13 | return decimalValue . compareTo ( new BigDecimal ( Integer . MIN_VALUE ) ) >= 0 && decimalValue . compareTo ( new BigDecimal ( Integer . MAX_VALUE ) ) <= 0 ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld132.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | public class AixcoderOld132 extends GenerateMethodBase { 9 | public String parseDate(String weiboTimeStr) 10 | { 11 | // 将字符串转换为日期 12 | //Date weiboTime = parseWeiboDate ( weiboTimeStr ) ; 13 | // 创建一个日期格式 14 | SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; 15 | // 将时间转换为字符串 16 | String weiboTimeStr2 = sdf . format ( weiboTimeStr ) ; 17 | return weiboTimeStr2 ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld133.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | public class AixcoderOld133 extends GenerateMethodBase { 8 | public long currentMonthStartUnixTime() 9 | { 10 | Calendar cal = Calendar . getInstance ( ) ; 11 | cal . set ( Calendar . DAY_OF_MONTH , 1 ) ; 12 | return cal . getTimeInMillis ( ) / 1000 ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld135.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld135 extends GenerateMethodBase { 5 | public Short multiply(Short a, Short b) 6 | { 7 | if ( a == 0 || b == 0 ) { 8 | return 0 ; 9 | } 10 | int bigNumber = Integer . max ( Math . abs ( a ) , Math . abs ( b ) ) ; 11 | int smallNumber = Integer . min ( Math . abs ( a ) , Math . abs ( b ) ) ; 12 | int maxMultiplier = Short . MAX_VALUE / bigNumber ; 13 | if ( smallNumber < maxMultiplier ) { 14 | return Integer . valueOf ( a * b ) . shortValue ( ) ; 15 | } else { 16 | if ( ( a > 0 && b < 0 ) || ( a < 0 && b > 0 ) ) { 17 | return Short . MIN_VALUE ; 18 | } else { 19 | return Short . MAX_VALUE ; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld137.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.net.http.HttpRequest; 6 | 7 | public class AixcoderOld137 extends GenerateMethodBase { 8 | public String getIPAddr(HttpRequest request){ 9 | return ""; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld138.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld138 extends GenerateMethodBase { 6 | public String toBinary(byte[] pBytes) { 7 | StringBuilder result = new StringBuilder(); 8 | for (byte b : pBytes) { 9 | for (int j = 7; j >= 0; j--) { 10 | result.append(((b & 1) == 0) ? '0' : '1'); 11 | b >>= 1; 12 | } 13 | } 14 | return result.toString(); 15 | } 16 | 17 | public static void main(String[] args) { 18 | System.out.println(new AixcoderOld138().toBinary(new byte[]{0x01, 0x02})); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld14.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld14 extends GenerateMethodBase { 5 | public void init(int[][] arr, int n) 6 | { 7 | for ( int i = 0 ; i < n ; i ++ ) { 8 | for ( int j = 0 ; j < n ; j ++ ) { 9 | arr [ i ] [ j ] = ( int ) ( Math . random ( ) * 10 ) ; 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld142.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld142 extends GenerateMethodBase { 5 | public String getTopDomain(String url) 6 | { 7 | if ( url . endsWith ( "/" ) ) { 8 | url = url . substring ( 0 , url . length ( ) -1 ) ; 9 | } 10 | String [ ] split = url . split ( "/" ) ; 11 | return split [ split . length -1 ] ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld143.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | public class AixcoderOld143 extends GenerateMethodBase { 8 | public boolean matchesPattern(String _string, Pattern[] _patterns) 9 | { 10 | for ( Pattern p : _patterns ) { 11 | if ( p . matcher ( _string ) . matches ( ) ) { 12 | return true ; 13 | } 14 | } 15 | return false ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld145.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld145 extends GenerateMethodBase { 6 | public boolean equals(Object[] array, Object[] other) { 7 | int length = array.length; 8 | if (length != other.length) { 9 | return false; 10 | } 11 | for (int i = 0; i < length; i++) { 12 | if (!(array[i].equals(other[i]))) { 13 | return false; 14 | } 15 | } 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld146.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.reflect.Method; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | public class AixcoderOld146 extends GenerateMethodBase { 10 | public Set getMethods(ClassLoader classLoader, String className) 11 | throws ClassNotFoundException { 12 | Set < String > methods = new HashSet< >( ) ; 13 | Class < ? > clazz = classLoader . loadClass ( className ) ; 14 | for ( Method method : clazz . getDeclaredMethods ( ) ) { 15 | methods . add ( method . getName ( ) ) ; 16 | } 17 | return methods ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld147.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.concurrent.FutureTask; 6 | 7 | public class AixcoderOld147 extends GenerateMethodBase { 8 | public String getPid(FutureTask t) { 9 | // if (t != null) { 10 | // Object o = t.result; 11 | // if (o != null) { 12 | // return o.toString(); 13 | // } 14 | // } 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld149.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.*; 6 | 7 | public class AixcoderOld149 extends GenerateMethodBase { 8 | public float getRadian(Point A, Point B) { 9 | if (A == null || B == null) { 10 | return 0; 11 | } 12 | float dx = B.x - A.x; 13 | float dy = B.y - A.y; 14 | return (float) Math.atan(dy / dx); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld151.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld151 extends GenerateMethodBase { 5 | public Integer[] asObjectArray(int[] array) 6 | { 7 | Integer [ ] objectArray = new Integer [ array . length ] ; 8 | for ( int i = 0 ; i < array . length ; i ++ ) objectArray [ i ] = array [ i ] ; 9 | return objectArray ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld152.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | 7 | public class AixcoderOld152 extends GenerateMethodBase { 8 | public String toMd5Code(String str) 9 | { 10 | if ( null == str ) { 11 | return null ; 12 | } 13 | String code = "" ; 14 | try { 15 | code = new String ( str . getBytes ( "UTF-8" ) ) ; 16 | } catch ( UnsupportedEncodingException e ) { 17 | e . printStackTrace ( ) ; 18 | } 19 | return code ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld153.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld153 extends GenerateMethodBase { 5 | public byte[] calculateC2(byte[] m, byte[] t) 6 | { 7 | if ( m == null || m . length == 0 || t == null || t . length == 0 ) { 8 | return null ; 9 | } 10 | byte [ ] c2 = new byte [ m . length ] ; 11 | for ( int i = 0 ; i < m . length ; i ++ ) { 12 | c2 [ i ] = ( byte ) ( m [ i ] ^ t [ i % t . length ] ) ; 13 | } 14 | return c2 ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld154.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.net.MalformedURLException; 6 | import java.net.URL; 7 | 8 | public class AixcoderOld154 extends GenerateMethodBase { 9 | public URL getUrlFile(String fileName) 10 | { 11 | URL url = null ; 12 | if ( fileName . startsWith ( "http" ) ) { 13 | try { 14 | url = new URL ( fileName ) ; 15 | } catch ( MalformedURLException e ) { 16 | e . printStackTrace ( ) ; 17 | } 18 | } else { 19 | ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; 20 | if ( classLoader != null ) { 21 | url = classLoader . getResource ( fileName ) ; 22 | } 23 | } 24 | return url ; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld156.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld156 extends GenerateMethodBase { 5 | public void addTo(float[] arrayA, float[] arrayB) 6 | { 7 | if ( arrayA . length != arrayB . length ) { 8 | throw new RuntimeException ( "The two arrays must have the same length!" ) ; 9 | } 10 | for ( int i = 0 ; i < arrayA . length ; i ++ ) { 11 | arrayA [ i ] += arrayB [ i ] ; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld157.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld157 extends GenerateMethodBase { 5 | public int lastIndexOf(float value, float[] array) 6 | { 7 | for ( int i = array . length -1 ; i >= 0 ; i -- ) { 8 | if ( array [ i ] == value ) { 9 | return i ; 10 | } 11 | } 12 | return -1 ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld16.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld16 extends GenerateMethodBase { 5 | public int hashCode(double[] vector) 6 | { 7 | if ( vector == null ) { 8 | return 0 ; 9 | } 10 | int h = 1 ; 11 | for ( double element : vector ) { 12 | int x = (int) Double . doubleToRawLongBits ( element ) ; 13 | h = 31 * h + x ; 14 | } 15 | return h ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld160.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Random; 8 | 9 | public class AixcoderOld160 extends GenerateMethodBase { 10 | public List doDrawRandom(List users, int count) { 11 | List result = new ArrayList<>(); 12 | for (int i = 0; i < count; i++) { 13 | result.add(users.get(new Random().nextInt(users.size()))); 14 | } 15 | return result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld161.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.Point; 6 | import java.util.List; 7 | 8 | public class AixcoderOld161 extends GenerateMethodBase { 9 | public Point getCenter(List points) 10 | { 11 | if ( points . size ( ) == 0 ) { 12 | return null ; 13 | } 14 | int x = 0 ; 15 | int y = 0 ; 16 | for ( Point p : points ) { 17 | if ( p != null ) { 18 | x += p . x ; 19 | y += p . y ; 20 | } 21 | } 22 | return new Point ( x / points . size ( ) , y / points . size ( ) ) ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld164.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.HashSet; 7 | import java.util.Map; 8 | import java.util.Set; 9 | 10 | public class AixcoderOld164 extends GenerateMethodBase { 11 | public Map> reverseMapIntoValueSetMap(Map map) 12 | { 13 | Map < V , Set < K > > reverseMap = new HashMap< V , Set < K > >( ) ; 14 | for ( Map . Entry < K , V > entry : map . entrySet ( ) ) { 15 | Set < K > keys = reverseMap . get ( entry . getValue ( ) ) ; 16 | if ( keys == null ) { 17 | keys = new HashSet< K >( ) ; 18 | reverseMap . put ( entry . getValue ( ) , keys ) ; 19 | } 20 | keys . add ( entry . getKey ( ) ) ; 21 | } 22 | return reverseMap ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld165.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Base64; 6 | 7 | public class AixcoderOld165 extends GenerateMethodBase { 8 | public byte[] base64decode(String base64string) 9 | { 10 | if ( base64string . length ( ) < 1 ) { 11 | return null ; 12 | } 13 | return Base64. getDecoder ( ) . decode ( base64string ) ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld166.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | public class AixcoderOld166 extends GenerateMethodBase { 8 | public T initByReflect(String name, String value, T t) 9 | { 10 | Class < ? > clazz = t . getClass ( ) ; 11 | try { 12 | Field field = clazz . getDeclaredField ( name ) ; 13 | field . setAccessible ( true ) ; 14 | field . set ( t , value ) ; 15 | } catch ( Exception e ) { 16 | e . printStackTrace ( ) ; 17 | } 18 | return t ; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld167.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | 9 | public class AixcoderOld167 extends GenerateMethodBase { 10 | public List array2List(T[] array) 11 | { 12 | List < T > list = new ArrayList< >( array . length ) ; 13 | Collections. addAll ( list , array ) ; 14 | return list ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld168.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class AixcoderOld168 extends GenerateMethodBase { 9 | public List getWeekDate() 10 | { 11 | List < String > list = new ArrayList< String >( ) ; 12 | for ( int i = 0 ; i < 7 ; i ++ ) { 13 | //list . add ( getShortDate ( ) ) ; 14 | } 15 | return list ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld169.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public class AixcoderOld169 extends GenerateMethodBase { 8 | public long remaining(ByteBuffer[] buffers) 9 | { 10 | long size = 0 ; 11 | for ( ByteBuffer buffer : buffers ) { 12 | size += buffer . remaining ( ) ; 13 | } 14 | return size ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld17.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.nio.charset.Charset; 6 | import java.nio.charset.IllegalCharsetNameException; 7 | import java.nio.charset.UnsupportedCharsetException; 8 | 9 | public class AixcoderOld17 extends GenerateMethodBase { 10 | public Charset charsetForName(String charsetName) 11 | { 12 | if ( charsetName == null ) { 13 | return null ; 14 | } 15 | try { 16 | return Charset . forName ( charsetName ) ; 17 | } catch ( IllegalCharsetNameException icne ) { 18 | throw new IllegalArgumentException ( "Unsupported charset " + charsetName , icne ) ; 19 | } catch ( UnsupportedCharsetException uce ) { 20 | throw new IllegalArgumentException ( "Unsupported charset " + charsetName , uce ) ; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld171.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld171 extends GenerateMethodBase { 5 | public String rvZeroAndDot(String s) 6 | { 7 | if ( s . isEmpty ( ) ) { 8 | return "0" ; 9 | } 10 | if ( s . indexOf ( "." ) > 0 ) { 11 | s = s . replaceAll ( "0+?$" , "" ) ; 12 | // 如最后一位是.则去掉 13 | s = s . replaceAll ( "[.]$" , "" ) ; 14 | } 15 | return s ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld172.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.math.BigDecimal; 6 | 7 | public class AixcoderOld172 extends GenerateMethodBase { 8 | public String bigDecimalSubtract(String str, String str1) 9 | { 10 | BigDecimal bd = new BigDecimal ( str ) ; 11 | BigDecimal bd1 = new BigDecimal ( str1 ) ; 12 | //return rvZeroAndDot ( bd . subtract ( bd1 ) . toPlainString ( ) ) ; 13 | return ""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld173.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | 7 | public class AixcoderOld173 extends GenerateMethodBase { 8 | public String getFileExtension(File file) 9 | { 10 | String filename = file . getName ( ) ; 11 | int i = filename . lastIndexOf ( '.' ) ; 12 | if ( i > 0 && i < filename . length ( ) -1 ) { 13 | return filename . substring ( i + 1 ) . toLowerCase ( ) ; 14 | } 15 | return null ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld174.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld174 extends GenerateMethodBase { 5 | public boolean isInteger(String numberString) 6 | { 7 | try { 8 | Integer . parseInt ( numberString ) ; 9 | return true ; 10 | } catch ( NumberFormatException ex ) { 11 | return false ; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld176.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld176 extends GenerateMethodBase { 5 | public boolean getBinaryState(int targetInteger, int position) { 6 | if (position < 1 || position > 32) { 7 | throw new IllegalArgumentException("Position out of bound.Should be between 1 and 32."); 8 | } 9 | 10 | int value = 1 << (position - 1); 11 | return (targetInteger & value) == value; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld177.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.management.ManagementFactory; 6 | 7 | public class AixcoderOld177 extends GenerateMethodBase { 8 | public String getProcessId() 9 | { 10 | String name = ManagementFactory. getRuntimeMXBean ( ) . getName ( ) ; 11 | String pid = name . split ( "@" ) [ 0 ] ; 12 | return pid ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld178.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld178 extends GenerateMethodBase { 5 | public int versionCompare(String v1, String v2) 6 | { 7 | String [ ] v1Parts = v1 . split ( "\\." ) ; 8 | String [ ] v2Parts = v2 . split ( "\\." ) ; 9 | int i = 0 ; 10 | while ( i < v1Parts . length && i < v2Parts . length && v1Parts [ i ] . equals ( v2Parts [ i ] ) ) { 11 | i ++ ; 12 | } 13 | if ( i < v1Parts . length && i < v2Parts . length ) { 14 | return Integer . valueOf ( v1Parts [ i ] ) . compareTo ( Integer . valueOf ( v2Parts [ i ] ) ) ; 15 | } 16 | return Integer . valueOf ( v1Parts [ v1Parts . length -1 ] ) . compareTo ( Integer . valueOf ( v2Parts [ v2Parts . length -1 ] ) ) ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld179.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class AixcoderOld179 extends GenerateMethodBase { 8 | public Long incrBy(Map valMap, String key, Long integer) { 9 | if (valMap.containsKey(key)) { 10 | return valMap.put(key, valMap.get(key) + integer); 11 | } else { 12 | valMap.put(key, integer); 13 | return valMap.get(key); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld18.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld18 extends GenerateMethodBase { 5 | public byte[] readBytes(java.io.InputStream in, int len) 6 | throws java . io . IOException { 7 | byte [ ] buf = new byte [ len ] ; 8 | int count = 0 ; 9 | while ( count < len ) { 10 | int numRead = in . read ( buf , count , len - count ) ; 11 | if ( numRead < 0 ) { 12 | throw new java . io . EOFException ( ) ; 13 | } 14 | count += numRead ; 15 | } 16 | return buf ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld180.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld180 extends GenerateMethodBase { 5 | public boolean isBin(String bin) 6 | { 7 | if ( bin == null || bin . length ( ) % 8 != 0 ) { 8 | return false ; 9 | } 10 | return true ; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld182.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class AixcoderOld182 extends GenerateMethodBase { 9 | public String[] filter(String[] word_list) 10 | { 11 | List< String > results = new ArrayList< String >( ) ; 12 | for ( String w : word_list ) { 13 | //if ( ! FILTER_CHARS . contains ( w ) ) { 14 | //results . add ( w . toLowerCase ( ) ) ; 15 | //} 16 | } 17 | return results . toArray ( new String [ results . size ( ) ] ) ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld183.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.math.BigDecimal; 6 | 7 | public class AixcoderOld183 extends GenerateMethodBase { 8 | public BigDecimal add(BigDecimal aVal, BigDecimal bVal) 9 | { 10 | if ( aVal == null ) { 11 | aVal = BigDecimal . ZERO ; 12 | } 13 | if ( bVal == null ) { 14 | bVal = BigDecimal . ZERO ; 15 | } 16 | return aVal . add ( bVal ) ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld186.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld186 extends GenerateMethodBase { 5 | public boolean isJdk7u40Above() 6 | { 7 | //checkJdkVersion ( ) ; 8 | //return _currentVersion . compareVersion ( 1.7 , 0 , 40 ) >= 0 ; 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld19.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class AixcoderOld19 extends GenerateMethodBase { 9 | public Map parseQueryString(String queryString) 10 | { 11 | Map < String , String > map = new HashMap< >( ) ; 12 | if ( queryString != null ) { 13 | String [ ] parameters = queryString . split ( "&" ) ; 14 | for ( String parameter : parameters ) { 15 | String [ ] keyValue = parameter . split ( "=" ) ; 16 | map . put ( keyValue [ 0 ] , keyValue . length == 2 ? keyValue [ 1 ] : null ) ; 17 | } 18 | } 19 | return map ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld20.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld20 extends GenerateMethodBase { 5 | public Object get(Object[] array, int index) 6 | { 7 | if ( array == null ) { 8 | return null ; 9 | } 10 | if ( index < 0 ) { 11 | return null ; 12 | } 13 | if ( index >= array . length ) { 14 | return null ; 15 | } 16 | return array [ index ] ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld21.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class AixcoderOld21 extends GenerateMethodBase { 9 | public void putAdditionalProperty(String key, Object value, Map additionalProperties) 10 | { 11 | if ( additionalProperties == null ) { 12 | additionalProperties = new HashMap< String , Object >( ) ; 13 | } 14 | additionalProperties . put ( key , value ) ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld22.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.util.Base64; 8 | 9 | public class AixcoderOld22 extends GenerateMethodBase { 10 | public String readImageData(String filename) 11 | throws IOException { 12 | FileInputStream fis = new FileInputStream ( filename ) ; 13 | byte [ ] data = new byte [ fis . available ( ) ] ; 14 | fis . read ( data ) ; 15 | fis . close ( ) ; 16 | return Base64.getEncoder().encodeToString(data); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld23.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld23 extends GenerateMethodBase { 5 | public float distance(float x0, float y0, float x1, float y1) 6 | { 7 | float dx = x1 - x0 ; 8 | float dy = y1 - y0 ; 9 | return ( float ) Math . sqrt ( dx * dx + dy * dy ) ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld24.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.*; 6 | import java.util.Collection; 7 | 8 | public class AixcoderOld24 extends GenerateMethodBase { 9 | public void writeFile(Collection lines, File file) 10 | throws IOException { 11 | if ( file == null ) { 12 | throw new IOException ( "File is null" ) ; 13 | } 14 | if ( ! file . exists ( ) ) { 15 | file . createNewFile ( ) ; 16 | } 17 | FileOutputStream fos = new FileOutputStream ( file ) ; 18 | BufferedOutputStream bos = new BufferedOutputStream ( fos ) ; 19 | PrintWriter writer = new PrintWriter ( bos ) ; 20 | for ( String line : lines ) { 21 | writer . println ( line ) ; 22 | } 23 | writer . close ( ) ; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld25.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld25 extends GenerateMethodBase { 6 | public final String toHex(byte[] byteArr) { 7 | if (byteArr == null) 8 | return ""; 9 | // return toHex(byteArr, byteArr.length); 10 | return ""; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld26.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.FileInputStream; 6 | import java.io.FileNotFoundException; 7 | 8 | public class AixcoderOld26 extends GenerateMethodBase { 9 | public java.io.InputStream getInputStream(String filepath) 10 | { 11 | java . io . InputStream is = null ; 12 | try { 13 | is = new FileInputStream( filepath ) ; 14 | } catch ( FileNotFoundException e ) { 15 | e . printStackTrace ( ) ; 16 | } 17 | return is ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld28.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class AixcoderOld28 extends GenerateMethodBase { 8 | public java.util.List split(String sequence, String delimiter) 9 | { 10 | java . util . List < String > result = new ArrayList< String >( ) ; 11 | int start = 0 ; 12 | int index = 0 ; 13 | while ( ( index = sequence . indexOf ( delimiter , start ) ) != -1 ) { 14 | result . add ( sequence . substring ( start , index ) ) ; 15 | start = index + delimiter . length ( ) ; 16 | } 17 | result . add ( sequence . substring ( start ) ) ; 18 | return result ; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld29.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld29 extends GenerateMethodBase { 5 | public double euclideanDistance(double[] p, double[] q) 6 | { 7 | double distance = 0 ; 8 | for ( int i = 0 ; i < p . length ; i ++ ) { 9 | distance += ( p [ i ] - q [ i ] ) * ( p [ i ] - q [ i ] ) ; 10 | } 11 | return Math . sqrt ( distance ) ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld3.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.BufferedWriter; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | 9 | public class AixcoderOld3 extends GenerateMethodBase { 10 | public void writeToFile(String content, String fileName) 11 | throws IOException { 12 | try (FileWriter fw = new FileWriter ( fileName ); 13 | BufferedWriter bw = new BufferedWriter ( fw ) ) { 14 | bw . write ( content ) ; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld30.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Iterator; 6 | import java.util.Map; 7 | import java.util.WeakHashMap; 8 | 9 | public class AixcoderOld30 extends GenerateMethodBase { 10 | public Map.Entry getEntry(Map map, K key) 11 | { 12 | 13 | Iterator< Map . Entry < K , V > > it = map . entrySet ( ) . iterator ( ) ; 14 | while ( it . hasNext ( ) ) { 15 | Map . Entry < K , V > e = it . next ( ) ; 16 | if ( key . equals ( e . getKey ( ) ) ) { 17 | return e ; 18 | } 19 | } 20 | return null ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld31.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld31 extends GenerateMethodBase { 6 | public int indexOf(int[] array, int element) { 7 | if (array == null) { 8 | return -1; 9 | } 10 | for (int i = 0; i < array.length; i++) { 11 | if (array[i] == element) { 12 | return i; 13 | } 14 | } 15 | return -1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld32.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld32 extends GenerateMethodBase { 5 | public int min(int[] array) 6 | { 7 | // Validates input 8 | if ( array == null ) { 9 | throw new IllegalArgumentException ( "The Array must not be null" ) ; 10 | } else if ( array . length == 0 ) { 11 | throw new IllegalArgumentException ( "Array cannot be empty." ) ; 12 | } 13 | // Finds and returns min 14 | int min = array [ 0 ] ; 15 | for ( int j = 1 ; j < array . length ; j ++ ) { 16 | if ( array [ j ] < min ) { 17 | min = array [ j ] ; 18 | } 19 | } 20 | return min ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld33.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld33 extends GenerateMethodBase { 6 | public double logSum(double[] x) { 7 | double sum = 0.0; 8 | for (int i = 0; i < x.length; i++) { 9 | sum += Math.log(x[i]); 10 | } 11 | return sum; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld34.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld34 extends GenerateMethodBase { 5 | public void sortServers(int[] serverIds) 6 | { 7 | int size = serverIds . length ; 8 | int lowest ; 9 | for ( int i = 0 ; i < size ; i ++ ) { 10 | lowest = i ; 11 | for ( int j = i + 1 ; j < size ; j ++ ) { 12 | if ( serverIds [ j ] < serverIds [ lowest ] ) 13 | lowest = j ; 14 | } 15 | if ( lowest != i ) { 16 | int temp = serverIds [ i ] ; 17 | serverIds [ i ] = serverIds [ lowest ] ; 18 | serverIds [ lowest ] = temp ; 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld35.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld35 extends GenerateMethodBase { 5 | public void ensureNotNull(Object obj) 6 | { 7 | if ( obj == null ) { 8 | throw new IllegalArgumentException ( "Object must not be null" ) ; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld36.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld36 extends GenerateMethodBase { 5 | public String extractFileName(String path) 6 | { 7 | int lastSlashIndex = path . lastIndexOf ( '/' ) ; 8 | if ( lastSlashIndex == -1 ) { 9 | lastSlashIndex = path . lastIndexOf ( '\\' ) ; 10 | } 11 | return ( lastSlashIndex != -1 ? path . substring ( lastSlashIndex + 1 ) : path ) ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld37.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Random; 6 | 7 | public class AixcoderOld37 extends GenerateMethodBase { 8 | public void fillMatrix_1D(double[] m) 9 | { 10 | Random r = new Random ( 2 ) ; 11 | for ( int i = 0 ; i < m . length ; i ++ ) { 12 | m [ i ] = r . nextDouble ( ) ; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld38.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld38 extends GenerateMethodBase { 5 | public int linearSearch(int[] arr, int key) 6 | { 7 | for ( int i = 0 ; i < arr . length ; i ++ ) { 8 | if ( key == arr [ i ] ) { 9 | return i ; 10 | } 11 | } 12 | return -1 ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld39.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | 8 | public class AixcoderOld39 extends GenerateMethodBase { 9 | public String generateTempFile(String dir) 10 | { 11 | try { 12 | File tempFile = File . createTempFile ( "tempFileGenerator" , ".tmp" ) ; 13 | tempFile . deleteOnExit ( ) ; 14 | return tempFile . getAbsolutePath ( ) ; 15 | } catch ( IOException e ) { 16 | throw new RuntimeException ( e ) ; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld4.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.IOException; 6 | import java.io.Reader; 7 | 8 | public class AixcoderOld4 extends GenerateMethodBase { 9 | public void close(Reader reader) 10 | { 11 | if ( reader != null ) { 12 | try { 13 | reader . close ( ) ; 14 | } catch ( IOException e ) { 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld40.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld40 extends GenerateMethodBase { 5 | public char getChar(StringBuffer sb, int i) 6 | { 7 | if ( i < sb . length ( ) ) { 8 | return sb . charAt ( i ) ; 9 | } else { 10 | return ' ' ; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld41.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class AixcoderOld41 extends GenerateMethodBase { 9 | public Map getAllUpperCase(Map map) 10 | { 11 | if ( map == null ) { 12 | return null ; 13 | } 14 | Map < String , Object > tempMap = new HashMap< >( ) ; 15 | for ( Map . Entry < String , Object > entry : map . entrySet ( ) ) { 16 | String key = entry . getKey ( ) . toUpperCase ( ) ; 17 | tempMap . put ( key , entry . getValue ( ) ) ; 18 | } 19 | return tempMap ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld42.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | public class AixcoderOld42 extends GenerateMethodBase { 9 | public String getLastYearDate() 10 | { 11 | Date date = new Date ( ) ; 12 | // 可以方便地修改日期格式 13 | SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyy" ) ; 14 | String years = dateFormat . format ( date ) ; 15 | return years ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld43.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class AixcoderOld43 extends GenerateMethodBase { 9 | public String updateUrl(String url, String key, String value) 10 | { 11 | Map< String , String > map = new HashMap< >( ) ; 12 | map . put ( key , value ) ; 13 | return ""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld44.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | public class AixcoderOld44 extends GenerateMethodBase { 9 | public void removeNullValue(Map map) 10 | { 11 | Set< String > keySet = map . keySet ( ) ; 12 | for ( String key : keySet ) { 13 | Object obj = map . get ( key ) ; 14 | if ( obj == null || "" . equals ( obj . toString ( ) . trim ( ) ) ) { 15 | map . remove ( key ) ; 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld45.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | public class AixcoderOld45 extends GenerateMethodBase { 9 | public int getYear(Date date) 10 | { 11 | Calendar calendar = Calendar . getInstance ( ) ; 12 | calendar . setTime ( date ) ; 13 | return calendar . get ( Calendar . YEAR ) ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld46.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld46 extends GenerateMethodBase { 6 | public void matrixMultiply(double[][] A, double[][] B) { 7 | //checkMatrixDimensions ( A , B ) ; 8 | for (int i = 0; i < A.length; i++) { 9 | for (int j = 0; j < A[0].length; j++) { 10 | A[i][j] = A[i][j] * B[i][j]; 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld47.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.reflect.Field; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class AixcoderOld47 extends GenerateMethodBase { 10 | public List getFields(Class clazz) 11 | { 12 | if ( null == clazz ) { 13 | return null ; 14 | } 15 | List < Field > fields = new ArrayList< Field >( ) ; 16 | for ( Field field : clazz . getFields ( ) ) { 17 | fields . add ( field ) ; 18 | } 19 | return fields ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld48.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Collection; 6 | import java.util.Set; 7 | 8 | public class AixcoderOld48 extends GenerateMethodBase { 9 | public void addAll(Set set, Collection collection) 10 | { 11 | for ( int i : collection ) { 12 | set . add ( i ) ; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld49.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld49 extends GenerateMethodBase { 5 | public byte[] longToBytes(long x) 6 | { 7 | byte [ ] b = new byte [ 8 ] ; 8 | for ( int i = 0 ; i < 8 ; i ++ ) { 9 | b [ i ] = ( byte ) x ; 10 | x >>>= 8 ; 11 | } 12 | return b ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld5.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld5 extends GenerateMethodBase { 5 | public float max(float a, float b, float c) 6 | { 7 | float max = Math . max ( a , b ) ; 8 | max = Math . max ( max , c ) ; 9 | return max ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld50.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld50 extends GenerateMethodBase { 5 | public String bytesToHexString(byte[] src) 6 | { 7 | StringBuilder stringBuilder = new StringBuilder ( ) ; 8 | if ( src == null || src . length <= 0 ) { 9 | return null ; 10 | } 11 | for ( int i = 0 ; i < src . length ; i ++ ) { 12 | int v = src [ i ] & 0xFF ; 13 | String hv = Integer . toHexString ( v ) ; 14 | if ( hv . length ( ) < 2 ) { 15 | stringBuilder . append ( 0 ) ; 16 | } 17 | stringBuilder . append ( hv ) ; 18 | } 19 | return stringBuilder . toString ( ) ; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld51.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld51 extends GenerateMethodBase { 5 | public int hashCode(byte[] byteArr) 6 | { 7 | int hashCode = 0 ; 8 | for ( int i = 0 ; i < byteArr . length ; i ++ ) { 9 | // bit set index of byte i is index of bit at which the byte i is set 10 | int bitIndex = i % Byte . SIZE ; 11 | int arrayIndex = i / Byte . SIZE ; 12 | 13 | } 14 | return hashCode ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld52.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class AixcoderOld52 extends GenerateMethodBase { 8 | public void remove(Map mapObj, Integer key) 9 | { 10 | if ( mapObj == null || key == null ) { 11 | return ; 12 | } 13 | mapObj . remove ( key ) ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld53.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld53 extends GenerateMethodBase { 5 | public Integer[] toObjectArray(int[] array) 6 | { 7 | Integer [ ] result = new Integer [ array . length ] ; 8 | for ( int i = 0 ; i < array . length ; i ++ ) { 9 | result [ i ] = array [ i ] ; 10 | } 11 | return result ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld55.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld55 extends GenerateMethodBase { 5 | public boolean isLetterOrDigit(String str) 6 | { 7 | String regex = "^[a-zA-Z0-9]+$" ; 8 | return str . matches ( regex ) ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld56.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld56 extends GenerateMethodBase { 5 | public boolean isLetter(char c) 6 | { 7 | if ( c >= 'a' && c <= 'z' ) 8 | return true ; 9 | else 10 | return false ; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld57.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | 7 | public class AixcoderOld57 extends GenerateMethodBase { 8 | public String joinPath(String path1, String path2) 9 | { 10 | if ( path1 . endsWith ( File. separator ) == false && path2 . endsWith ( File . separator ) == false ) { 11 | return path1 + path2 ; 12 | } else if ( path1 . endsWith ( File . separator ) ) { 13 | return path1 + path2 . substring ( 0 , path2 . length ( ) -1 ) ; 14 | } else if ( path2 . endsWith ( File . separator ) ) { 15 | return path1 + path2 . substring ( 0 , path2 . length ( ) -1 ) ; 16 | } else { 17 | return path1 + File . separator + path2 ; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld58.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld58 extends GenerateMethodBase { 5 | public byte[] intToByteArray(int value) 6 | { 7 | byte [ ] src = new byte [ 4 ] ; 8 | src [ 0 ] = ( byte ) ( value ) ; 9 | src [ 1 ] = ( byte ) ( ( value >>> 8 ) ) ; 10 | src [ 2 ] = ( byte ) ( ( value >>> 16 ) ) ; 11 | src [ 3 ] = ( byte ) ( ( value >>> 24 ) ) ; 12 | return src ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld6.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld6 extends GenerateMethodBase { 5 | public void putShort(byte[] data, short value, int offset) 6 | { 7 | data [ offset ] = ( byte ) ( ( value >>> 0 ) & 0xFF ) ; 8 | data [ offset + 1 ] = ( byte ) ( ( value >>> 8 ) & 0xFF ) ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld60.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld60 extends GenerateMethodBase { 6 | public String bytesToHex(byte[] bytes) { 7 | StringBuilder sbuf = new StringBuilder(); 8 | for (int idx = 0; idx < bytes.length; idx++) { 9 | int intVal = bytes[idx] & 0xff; 10 | if (intVal < 0x10) 11 | sbuf.append("0"); 12 | sbuf.append(Integer.toHexString(intVal).toUpperCase()); 13 | } 14 | return sbuf.toString(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld62.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld62 extends GenerateMethodBase { 6 | public int combinatorial(int n, int m) { 7 | if (n < 0 || m < 0) { 8 | throw new IllegalArgumentException("Combinatorial values cannot be negative"); 9 | } 10 | if (n > m) { 11 | int temp = n; 12 | n = m; 13 | m = temp; 14 | } 15 | int result = 1; 16 | for (int i = 1; i <= n; i++) { 17 | result *= i; 18 | } 19 | for (int i = 1; i <= m; i++) { 20 | result /= i; 21 | } 22 | return result; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld63.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld63 extends GenerateMethodBase { 5 | public boolean checkUsername(String username) 6 | { 7 | if ( username . length ( ) > 20 ) { 8 | return false ; 9 | } 10 | if ( username . length ( ) < 4 || username . length ( ) > 10 ) { 11 | return false ; 12 | } 13 | if ( ! username . matches ( "[a-zA-Z0-9_]+" ) ) { 14 | return false ; 15 | } 16 | return true ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld64.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | 8 | public class AixcoderOld64 extends GenerateMethodBase { 9 | public String getStringToday(String format) 10 | { 11 | Date currentTime = new Date ( ) ; 12 | SimpleDateFormat formatter = new SimpleDateFormat ( format ) ; 13 | String dateString = formatter . format ( currentTime ) ; 14 | return dateString ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld66.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class AixcoderOld66 extends GenerateMethodBase { 8 | public ArrayList merge(ArrayList list1, ArrayList list2) 9 | { 10 | if ( list1 == null ) { 11 | return list2 ; 12 | } else if ( list2 == null ) { 13 | return list1 ; 14 | } 15 | ArrayList < T > result = new ArrayList < T > ( ) ; 16 | result . addAll ( list1 ) ; 17 | for ( T elt : list2 ) { 18 | if ( ! result . contains ( elt ) ) { 19 | result . add ( elt ) ; 20 | } 21 | } 22 | return result ; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld67.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld67 extends GenerateMethodBase { 5 | public double[] multiplyTranspose(double[] vector, double[][] matrix) 6 | { 7 | double [ ] result = new double [ vector . length ] ; 8 | for ( int i = 0 ; i < vector . length ; i ++ ) { 9 | result [ i ] = 0 ; 10 | for ( int j = 0 ; j < matrix [ i ] . length ; j ++ ) { 11 | result [ i ] += vector [ i ] * matrix [ i ] [ j ] ; 12 | } 13 | } 14 | return result ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld68.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class AixcoderOld68 extends GenerateMethodBase { 8 | public String removeLast(ArrayList list) 9 | { 10 | if ( list . size ( ) == 0 ) 11 | return null ; 12 | return list . remove ( list . size ( ) -1 ) ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld69.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.LinkedList; 6 | 7 | public class AixcoderOld69 extends GenerateMethodBase { 8 | public int getMax(LinkedList list) { 9 | int max = list.getFirst(); 10 | for (int i = 1; i < list.size(); i++) { 11 | if (list.get(i) > max) { 12 | max = list.get(i); 13 | } 14 | } 15 | return max; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld7.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.net.URL; 9 | import java.util.Properties; 10 | 11 | public class AixcoderOld7 extends GenerateMethodBase { 12 | public Properties getProperties(String url) { 13 | Properties properties = new Properties(); 14 | try { 15 | properties.load(new URL(url).openStream()); 16 | } catch (IOException e) { 17 | e.printStackTrace(); 18 | } 19 | return properties; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld70.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | public class AixcoderOld70 extends GenerateMethodBase { 8 | public long elapsedTime(Calendar start, Calendar end) 9 | { 10 | if ( start == null || end == null ) { 11 | throw new IllegalArgumentException ( "The dates must not be null" ) ; 12 | } 13 | long startMs = start . getTimeInMillis ( ) ; 14 | long endMs = end . getTimeInMillis ( ) ; 15 | return ( endMs - startMs ) ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld71.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.zip.CRC32; 6 | 7 | public class AixcoderOld71 extends GenerateMethodBase { 8 | public long crc32(byte[] bytes) 9 | { 10 | CRC32 crc = new CRC32 ( ) ; 11 | crc . update ( bytes ) ; 12 | return crc . getValue ( ) ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld72.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld72 extends GenerateMethodBase { 5 | public T newInstance(Class clazz) 6 | { 7 | try { 8 | return clazz . newInstance ( ) ; 9 | } catch ( InstantiationException | IllegalAccessException e ) { 10 | throw new RuntimeException ( e ) ; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld73.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class AixcoderOld73 extends GenerateMethodBase { 8 | public void delete(List list, int start, int end) { 9 | if (start < 0 || end < start) 10 | return; 11 | if (end > list.size()) 12 | end = list.size(); 13 | for (int i = end - 1; i >= start; i--) { 14 | list.remove(i); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld78.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld78 extends GenerateMethodBase { 5 | public String replaceFirst(String str, String str1, String str2) 6 | { 7 | if ( str == null || str1 == null || str2 == null ) { 8 | return null ; 9 | } 10 | return str . replaceFirst ( str1 , str2 ) ; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld79.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | 8 | public class AixcoderOld79 extends GenerateMethodBase { 9 | public void write(byte[] b, int off, int len, OutputStream outputStream) 10 | throws IOException { 11 | if ( len < 0 ) { 12 | throw new IndexOutOfBoundsException ( ) ; 13 | } 14 | int c = 0 ; 15 | while ( c < len ) { 16 | int i = off + c ; 17 | if ( i < b . length ) { 18 | outputStream . write ( b , i , 1 ) ; 19 | } else { 20 | outputStream . write ( 0 ) ; 21 | } 22 | c ++ ; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld8.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld8 extends GenerateMethodBase { 5 | public int findMaxNumber(int[] nums) 6 | { 7 | if ( nums == null || nums . length == 0 ) { 8 | return 0 ; 9 | } 10 | int maxNumber = nums [ 0 ] ; 11 | for ( int i = 1 ; i < nums . length ; i ++ ) { 12 | if ( nums [ i ] > maxNumber ) { 13 | maxNumber = nums [ i ] ; 14 | } 15 | } 16 | return maxNumber ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld80.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Random; 6 | 7 | public class AixcoderOld80 extends GenerateMethodBase { 8 | public int randomInt(int origin, int bound) 9 | { 10 | Random random = new Random ( ) ; 11 | return origin + random . nextInt ( bound - origin ) ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld83.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class AixcoderOld83 extends GenerateMethodBase { 10 | public List getFiles(String dir) 11 | { 12 | List < String > list = new ArrayList< String >( ) ; 13 | File file = new File ( dir ) ; 14 | if ( ! file . exists ( ) ) { 15 | return list ; 16 | } 17 | File [ ] files = file . listFiles ( ) ; 18 | if ( files == null ) { 19 | return list ; 20 | } 21 | for ( File f : files ) { 22 | if ( f . isFile ( ) ) { 23 | list . add ( f . getName ( ) ) ; 24 | } 25 | } 26 | return list ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld84.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.*; 6 | 7 | public class AixcoderOld84 extends GenerateMethodBase { 8 | public Point rotateY(double angle, Point point) 9 | { 10 | double sin = Math . sin ( angle ) ; 11 | double cos = Math . cos ( angle ) ; 12 | int x = ( int ) Math . round ( point . x * cos - point . y * sin ) ; 13 | int y = ( int ) Math . round ( point . x * sin + point . y * cos ) ; 14 | return new Point ( x , y ) ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld85.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld85 extends GenerateMethodBase { 5 | public String appendTrailing(String str, String trailing) 6 | { 7 | if ( ( str=="" ) ) { 8 | return trailing ; 9 | } 10 | if ( ( trailing=="" ) ) { 11 | return str ; 12 | } 13 | return str + " " + trailing ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld86.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Collection; 6 | 7 | public class AixcoderOld86 extends GenerateMethodBase { 8 | public boolean containsKey(Collection collection, String key) 9 | { 10 | if ( collection == null || key == null ) { 11 | return false ; 12 | } 13 | return collection . contains ( key ) ; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld88.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class AixcoderOld88 extends GenerateMethodBase { 6 | public int hexStringToInt(String hexString) { 7 | if (hexString == null || hexString.equals("")) { 8 | return -1; 9 | } 10 | int result = 0; 11 | int index = 0; 12 | int n = 0; 13 | while (index < hexString.length() - 1) { 14 | n = Integer.valueOf(hexString.charAt(index)); 15 | if (n < 0) { 16 | return -1; 17 | } 18 | result = result + n * 16; 19 | index++; 20 | } 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld89.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import static java.lang.Integer.MAX_VALUE; 6 | 7 | public class AixcoderOld89 extends GenerateMethodBase { 8 | public boolean checkOverflow(int x, int y) { 9 | if (x < 0 || y < 0) { 10 | return true; 11 | } 12 | if (x > MAX_VALUE - y) { 13 | return true; 14 | } 15 | if (y > MAX_VALUE - x) { 16 | return true; 17 | } 18 | return false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld9.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.DateFormat; 6 | import java.util.Date; 7 | 8 | 9 | public class AixcoderOld9 extends GenerateMethodBase { 10 | public String date2String(final Date date, final DateFormat format) 11 | { 12 | if ( format != null ) { 13 | return format . format ( date ) ; 14 | } else { 15 | return null ; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld90.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashSet; 6 | import java.util.Map; 7 | 8 | public class AixcoderOld90 extends GenerateMethodBase { 9 | public void addToSet(Map> map, String key, Integer value) 10 | { 11 | HashSet < Integer > set = map . get ( key ) ; 12 | if ( set == null ) { 13 | set = new HashSet < Integer > ( ) ; 14 | map . put ( key , set ) ; 15 | } 16 | set . add ( value ) ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld91.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld91 extends GenerateMethodBase { 5 | public int average(int a, int b) 6 | { 7 | int sum = a + b ; 8 | return ( sum <= 0 ) ? 0 : ( sum >= 255 ) ? 255 : sum / 2 ; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld92.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld92 extends GenerateMethodBase { 5 | public void checkRange(int value, int min, int max) 6 | { 7 | if ( ( value < min ) || ( value > max ) ) { 8 | throw new IllegalArgumentException ( "Value is out of range : " + value ) ; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld94.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Random; 6 | 7 | public class AixcoderOld94 extends GenerateMethodBase { 8 | public int random(int[] array) 9 | { 10 | int index = new Random(). nextInt ( array . length ) ; 11 | return array [ index ] ; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld95.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld95 extends GenerateMethodBase { 5 | public boolean equals(Object o1, Object o2) 6 | { 7 | if ( o1 == o2 ) { 8 | return true ; 9 | } 10 | if ( o1 == null || o2 == null ) { 11 | return false ; 12 | } 13 | if ( o1 instanceof Number && o2 instanceof Number ) { 14 | return ( ( Number ) o1 ) . doubleValue ( ) == ( ( Number ) o2 ) . doubleValue ( ) ; 15 | } 16 | return o1 . equals ( o2 ) ; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld96.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld96 extends GenerateMethodBase { 5 | public double[] product(double[] columnVector,double[][] matrix) 6 | { 7 | if ( columnVector . length != matrix [ 0 ] . length ) { 8 | throw new IllegalArgumentException ( "The column vector and matrix must have the same length." ) ; 9 | } 10 | double [ ] product = new double [ matrix . length ] ; 11 | for ( int i = 0 ; i < matrix . length ; i ++ ) { 12 | product [ i ] = 0 ; 13 | for ( int j = 0 ; j < matrix [ 0 ] . length ; j ++ ) { 14 | product [ i ] += matrix [ i ] [ j ] * columnVector [ j ] ; 15 | } 16 | } 17 | return product ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld97.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Arrays; 6 | 7 | public class AixcoderOld97 extends GenerateMethodBase { 8 | public T[] concat(T[] a, T[] b) 9 | { 10 | T [ ] c = Arrays. copyOf ( a , a . length + b . length ) ; 11 | System . arraycopy ( b , 0 , c , a . length , b . length ) ; 12 | return c ; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/aixcoder/AixcoderOld99.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.aixcoder; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | public class AixcoderOld99 extends GenerateMethodBase { 5 | public String boolToString(boolean b) 6 | { 7 | if ( b ) { 8 | return "true" ; 9 | } else { 10 | return "false" ; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod1.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod1 extends GenerateMethodBase { 6 | /** 7 | * Creates a padding string of a certain length 8 | */ 9 | public String createPadding(int length, char padChar) { 10 | StringBuilder sb = new StringBuilder(); 11 | for (int i = 0; i < length; i++) { 12 | sb.append(padChar); 13 | } 14 | return sb.toString(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod10.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class GenerateMethod10 extends GenerateMethodBase { 10 | /** 11 | * Looks through the backups directory and assembles a list of all json backup files found. 12 | */ 13 | public List getBackupFiles(String dir) { 14 | List files = new ArrayList(); 15 | File dirFile = new File(dir); 16 | if (dirFile.exists()) { 17 | File[] backupFiles = dirFile.listFiles(); 18 | for (File backupFile : backupFiles) { 19 | if (backupFile.getName().endsWith(".json")) { 20 | files.add(backupFile.getName()); 21 | } 22 | } 23 | } 24 | return files; 25 | 26 | 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod101.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod101 extends GenerateMethodBase { 6 | /** 7 | * Create a copy of the Integer array 8 | */ 9 | public int[] copy(int[] arr) { 10 | int[] result = new int[arr.length]; 11 | for (int i = 0; i < arr.length; i++) { 12 | result[i] = arr[i]; 13 | } 14 | return result; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod102.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod102 extends GenerateMethodBase { 8 | /** 9 | * Returns the current number of entries in the map. 10 | */ 11 | public int size(Map map) { 12 | return map.size(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod103.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod103 extends GenerateMethodBase { 6 | /** 7 | * Returns true if two doubles are considered equal. Tests if the absolute difference between the two doubles has a difference less then a given double (epsilon) Returns true if two doubles are considered equal. Tests if the absolute difference between the two doubles has a difference less then a given double (epsilon) 8 | */ 9 | public boolean equals(double a, double b, double epsilon) { 10 | return Math.abs(a - b) < epsilon; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod104.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod104 extends GenerateMethodBase { 6 | /** 7 | * Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary. 8 | */ 9 | public void putShort(byte[] data, byte b, short s) { 10 | data[0] = b; 11 | data[1] = (byte)((s >>> 0) & 0xFF); 12 | data[2] = (byte)((s >>> 8) & 0xFF); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod105.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Iterator; 6 | 7 | public class GenerateMethod105 extends GenerateMethodBase { 8 | 9 | /** 10 | * Advances the iterator either forward or backward the specified number of steps. Negative values move backward, and positive values move forward. This is equivalent to repeatedly calling next() or previous(). 11 | */ 12 | public int next(Iterator iterator, int n) { 13 | int result = 0; 14 | for (int i = 0; i < n; i++) { 15 | result += iterator.next(); 16 | } 17 | return result; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod106.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod106 extends GenerateMethodBase { 6 | 7 | /** 8 | * 一维数组转为二维数组,width表示列数,height表示行数 9 | */ 10 | public int[][] arrayToMatrix(int[] m, int width, int height) { 11 | int[][] result = new int[height][width]; 12 | for (int i = 0; i < height; i++) { 13 | for (int j = 0; j < width; j++) { 14 | result[i][j] = m[i * width + j]; 15 | } 16 | } 17 | return result; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod107.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod107 extends GenerateMethodBase { 6 | 7 | /** 8 | * Verifies that the given array is not null or empty. 9 | */ 10 | public boolean checkNotNullOrEmpty(int[] array) { 11 | return array != null && array.length > 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod108.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod108 extends GenerateMethodBase { 6 | 7 | /** 8 | * Removes all white spaces from a string A whitespace is identified using the Java method Character.isWhiteSpace 9 | */ 10 | public String removeAllWhiteSpaces(String str) { 11 | StringBuilder sb = new StringBuilder(); 12 | for (int i = 0; i < str.length(); i++) { 13 | if (!Character.isWhitespace(str.charAt(i))) { 14 | sb.append(str.charAt(i)); 15 | } 16 | } 17 | return sb.toString(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod109.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod109 extends GenerateMethodBase { 6 | 7 | /** 8 | * subtract b from a 9 | */public String[] sub(String[] a, String[] b) { 10 | String[] result = new String[a.length]; 11 | for (int i = 0; i < a.length; i++) { 12 | result[i] = a[i] + "-" + b[i]; 13 | } 14 | return result; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod11.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod11 extends GenerateMethodBase { 6 | /** 7 | * Rearranges the elements of the specified subarray in random order. 8 | */ 9 | public void shuffle(int[] array) { 10 | for (int i = array.length - 1; i > 0; i--) { 11 | int j = (int) (Math.random() * (i + 1)); 12 | int temp = array[i]; 13 | array[i] = array[j]; 14 | array[j] = temp; 15 | } 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod110.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod110 extends GenerateMethodBase { 6 | 7 | /** 8 | * Converts the string argument into a float value. 9 | */ 10 | public float parseFloat(String floatStr) { 11 | return Float.parseFloat(floatStr); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod111.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod111 extends GenerateMethodBase { 6 | 7 | /** 8 | * Return true if the local path is a Windows absolute path. 9 | */ 10 | public boolean isWindowsAbsolutePath(String path) { 11 | return path.matches("^[a-zA-Z]:\\\\.*"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod112.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod112 extends GenerateMethodBase { 6 | 7 | /** 8 | * Calculates the distance between two points in high-dimensional space. 9 | */ 10 | public double length(double[] p0, double[] p1) { 11 | double sum = 0; 12 | for (int i = 0; i < p0.length; i++) { 13 | sum += (p0[i] - p1[i]) * (p0[i] - p1[i]); 14 | } 15 | return Math.sqrt(sum); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod113.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod113 extends GenerateMethodBase { 6 | 7 | /** 8 | * This function takes an array of words, and returns a string with all the words in the separated by a space. 9 | */ 10 | public String getStringfromStringArray(String[] array) { 11 | String result = ""; 12 | for (int i = 0; i < array.length; i++) { 13 | result += array[i] + " "; 14 | } 15 | return result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod114.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.util.zip.ZipFile; 8 | 9 | public class GenerateMethod114 extends GenerateMethodBase { 10 | 11 | /** 12 | * Check whether a file is actually a valid zip 13 | */ 14 | public boolean isValidZip(File zip) { 15 | try { 16 | ZipFile zipFile = new ZipFile(zip); 17 | return true; 18 | } catch (IOException e) { 19 | return false; 20 | } 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod115.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod115 extends GenerateMethodBase { 6 | 7 | /** 8 | * Parse a list of longs into strings. 9 | */ 10 | public String[] toTimestampStrs(long[] timestamps) { 11 | String[] timestampsStr = new String[timestamps.length]; 12 | for (int i = 0; i < timestamps.length; i++) { 13 | timestampsStr[i] = String.valueOf(timestamps[i]); 14 | } 15 | return timestampsStr; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod116.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod116 extends GenerateMethodBase { 6 | 7 | /** 8 | * Change the size of this array. Content between indexes 0 and min(size(), newSize) will be preserved. 9 | */ 10 | public int[] resize(int[] arr,long newSize) { 11 | int[] newArr = new int[(int)newSize]; 12 | int min = Math.min(arr.length, (int)newSize); 13 | for (int i = 0; i < min; i++) { 14 | newArr[i] = arr[i]; 15 | } 16 | arr = newArr; 17 | return arr; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod117.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod117 extends GenerateMethodBase { 6 | 7 | /** 8 | * 概述:截取指定长度的数组 9 | */ 10 | public byte[] subBytes(byte[] src, int pos, int count) { 11 | byte[] bs = new byte[count]; 12 | for (int i = 0; i < count; i++) { 13 | bs[i] = src[pos + i]; 14 | } 15 | return bs; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod118.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod118 extends GenerateMethodBase { 6 | 7 | /** 8 | * 返回不小于输入值value的最小整数 9 | */ 10 | public int floor(double val) { 11 | return (int) Math.floor(val); 12 | } 13 | 14 | // public static void main(String[] args) { 15 | // System.out.println(new GenerateMethod118().floor(23.2)); 16 | // } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod119.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod119 extends GenerateMethodBase { 6 | 7 | /** 8 | * 保留两位小数 9 | */ 10 | public String formatDouble(double val) { 11 | return String.format("%.2f", val); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod12.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod12 extends GenerateMethodBase { 8 | /** 9 | * Retrieves the value by specified int index of the given List. 10 | */ 11 | public String getValue(List list, int index) { 12 | return list.get(index); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod121.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod121 extends GenerateMethodBase { 6 | 7 | /** 8 | * Get the index of the next slash. 9 | */ 10 | public int getNextSlash(String path, int index) { 11 | int slashIndex = path.indexOf('/', index); 12 | if (slashIndex == -1) { 13 | return path.length(); 14 | } 15 | return slashIndex; 16 | } 17 | 18 | // public static void main(String[] args) { 19 | // System.out.println(new GenerateMethod121().getNextSlash("",1)); 20 | // } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod122.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod122 extends GenerateMethodBase { 6 | 7 | /** 8 | * Returns true iff all entries of (all subarrays of) the input array are >= 0. Returns true if the array is non-null, but empty 9 | */ 10 | public boolean isNonNegative(long[][] in) { 11 | if (in == null) { 12 | return true; 13 | } 14 | for (int i = 0; i < in.length; i++) { 15 | for (int j = 0; j < in[i].length; j++) { 16 | if (in[i][j] < 0) { 17 | return false; 18 | } 19 | } 20 | } 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod123.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod123 extends GenerateMethodBase { 6 | 7 | /** 8 | * Returns maximum possible integer, less or equal than oldValue, divisible by quantum. 9 | */ 10 | public int floor(int x, int quantum) { 11 | return x - x % quantum; 12 | } 13 | 14 | // public static void main(String[] args) { 15 | // System.out.println(10 - 10% 6); 16 | // } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod124.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod124 extends GenerateMethodBase { 8 | 9 | /** 10 | * Appends an item to the list. 11 | */ 12 | public void append(List list, String item) { 13 | list.add(item); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod126.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod126 extends GenerateMethodBase { 6 | 7 | /** 8 | * Unzip the contents of the given zip in the given directory (create it if it doesn't exist) 9 | */ 10 | public void unzip(String zipPath, String destDirPath) { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod127.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod127 extends GenerateMethodBase { 6 | 7 | /** 8 | * returns a array including given range. [start, end) 9 | */ 10 | public int[] range(int start, int end) { 11 | int[] result = new int[end - start]; 12 | for (int i = 0; i < result.length; i++) { 13 | result[i] = start + i; 14 | } 15 | return result; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod128.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | public class GenerateMethod128 extends GenerateMethodBase { 8 | 9 | /** 10 | * Clear the given calendar, setting to zero all time values less than or equal to that of the given field. For example, clearing to Calendar#HOUR will floor the time to nearest hour which occurred before or at the given time (e.g., 1:32 --> 1:30). 11 | */ 12 | public Calendar clearTo(Calendar c, int field) { 13 | return c; 14 | } 15 | 16 | // public static void main(String[] args) { 17 | // Calendar cal = Calendar.getInstance(); 18 | // System.out.println(cal.getTime()); 19 | // } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod129.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Calendar; 7 | 8 | public class GenerateMethod129 extends GenerateMethodBase { 9 | /** 10 | * 获取当前系统时间 minute分钟后 的时间 11 | */ 12 | public String getNowDate(int minute){ 13 | Calendar cal = Calendar.getInstance(); 14 | cal.add(Calendar.MINUTE, minute); 15 | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod13.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod13 extends GenerateMethodBase { 6 | /** 7 | * Returns a string, consisting of given length random char from given alphabet. 8 | */ 9 | public String randomString(int length, String alphabet) { 10 | StringBuilder sb = new StringBuilder(); 11 | for (int i = 0; i < length; i++) { 12 | sb.append(alphabet.charAt((int) (Math.random() * alphabet.length()))); 13 | } 14 | return sb.toString(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod130.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.math.BigDecimal; 6 | 7 | public class GenerateMethod130 extends GenerateMethodBase { 8 | /** 9 | * Check the given value is in int range. 10 | */ 11 | public boolean isDecimalWithinIntRange(BigDecimal decimalValue) 12 | { 13 | return decimalValue.compareTo(new BigDecimal(Integer.MAX_VALUE)) <= 0 && decimalValue.compareTo(new BigDecimal(Integer.MIN_VALUE)) >= 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod132.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod132 extends GenerateMethodBase { 6 | /** 7 | * 将微博时间字符串转换成yyyyMMddHHmmSS 微博时间字符串有: xx分钟前 今天 11:53 07月09日 13:36 2010-09-23 19:55:38 8 | */ 9 | public String parseDate(String weiboTimeStr) throws Exception { 10 | //生成代码有问题,暂时不生成 11 | throw new Exception("代码生成 invalid"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod133.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | public class GenerateMethod133 extends GenerateMethodBase { 8 | /** 9 | * 返回当月开始时间 10 | */ 11 | public long currentMonthStartUnixTime() { 12 | Calendar cal = Calendar.getInstance(); 13 | cal.set(Calendar.DAY_OF_MONTH, 1); 14 | cal.set(Calendar.HOUR_OF_DAY, 0); 15 | cal.set(Calendar.MINUTE, 0); 16 | cal.set(Calendar.SECOND, 0); 17 | cal.set(Calendar.MILLISECOND, 0); 18 | //System.out.println(cal.getTime()); 19 | return cal.getTimeInMillis(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod134.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod134 extends GenerateMethodBase { 6 | /** 7 | * Multiply Long and Double numbers. 8 | */ 9 | @Override 10 | public Long multiply(Long number, Double multiplier) { 11 | return (long)(number * multiplier); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod135.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod135 extends GenerateMethodBase { 6 | /** 7 | * Multiply two Short numbers. 8 | */ 9 | @Override 10 | public Short multiply(Short a, Short b) { 11 | return (short) (a * b); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod137.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.net.http.HttpRequest; 6 | 7 | public class GenerateMethod137 extends GenerateMethodBase { 8 | /** 9 | * 获取request的IP地址 10 | */ 11 | @Override 12 | public String getIPAddr(HttpRequest request) { 13 | // cannot resolve method name:request.remoteAddress() 14 | //return request.headers().firstValue("X-Forwarded-For").orElse(request.headers().firstValue("X-Real-IP").orElse(request.remoteAddress().getHostString())); 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod138.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod138 extends GenerateMethodBase { 6 | /** 7 | * Convert byte array to binary String 8 | */ 9 | @Override 10 | public String toBinary(byte[] pBytes) { 11 | StringBuilder sb = new StringBuilder(); 12 | for (byte b : pBytes) { 13 | sb.append(String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0')); 14 | } 15 | return sb.toString(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod139.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.reflect.Type; 6 | 7 | 8 | 9 | public class GenerateMethod139 extends GenerateMethodBase { 10 | /** 11 | * Convert arguments of a method (signature) to an array of Type objects. 12 | */ 13 | @Override 14 | public Type[] getArgumentTypes(String signature) { 15 | String[] args = signature.split("\\s"); 16 | Type[] types = new Type[args.length]; 17 | for (int i = 0; i < args.length; i++) { 18 | // types[i] = (Type) getType(args[i]); 19 | } 20 | return types; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod14.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod14 extends GenerateMethodBase { 6 | /** 7 | * 用1到n随机初始化二维数组 8 | */ 9 | public void init(int[][] arr, int n) { 10 | for (int i = 0; i < arr.length; i++) { 11 | for (int j = 0; j < arr[i].length; j++) { 12 | arr[i][j] = (int) (Math.random() * n) + 1; 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod140.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.nio.ByteBuffer; 6 | import java.nio.charset.Charset; 7 | 8 | public class GenerateMethod140 extends GenerateMethodBase { 9 | /** 10 | * Convert a partial buffer to a String. 11 | */ 12 | @Override 13 | public String toString(ByteBuffer buffer, int position, int length, Charset charset) { 14 | byte[] bytes = new byte[length]; 15 | buffer.position(position); 16 | buffer.get(bytes); 17 | return new String(bytes, charset); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod141.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod141 extends GenerateMethodBase { 6 | /** 7 | * 两个时间之间相差距离多少天,时间格式yyyy-MM-dd 8 | */ 9 | @Override 10 | public long getDistanceDays(String str1, String str2) { 11 | return 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod143.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | public class GenerateMethod143 extends GenerateMethodBase { 8 | /** 9 | * Returns true if the given String matches to one of the provided Patterns, false otherwise. 10 | */ 11 | @Override 12 | public boolean matchesPattern(String _string, Pattern[] _patterns) 13 | { 14 | for (Pattern pattern : _patterns) 15 | { 16 | if (pattern.matcher(_string).matches()) 17 | { 18 | return true; 19 | } 20 | } 21 | return false; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod144.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod144 extends GenerateMethodBase { 6 | /** 7 | * Extracts all the files in the given zip file to the input destination path. If zip file does not exist or destination path is invalid then an exception is thrown. 8 | */ 9 | public void extractAll(String destPath, String zipName) { 10 | // if (destPath == null || zipName == null) { 11 | // throw new IllegalArgumentException("destPath or zipName is null"); 12 | // } 13 | // File destDir = new File(destPath); 14 | // if (!destDir.exists() || !destDir.isDirectory()) { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod145.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod145 extends GenerateMethodBase { 6 | /** 7 | * 判断两个数组的内容是否相等 用于equals的比较 8 | */ 9 | @Override 10 | public boolean equals(Object[] array, Object[] other) { 11 | if (array == null || other == null) { 12 | return false; 13 | } 14 | if (array.length != other.length) { 15 | return false; 16 | } 17 | for (int i = 0; i < array.length; i++) { 18 | if (!array[i].equals(other[i])) { 19 | return false; 20 | } 21 | } 22 | return true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod146.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | 8 | public class GenerateMethod146 extends GenerateMethodBase { 9 | /** 10 | * Returns a set with all unique methodNames of methods. 11 | */ 12 | public Set getMethods(ClassLoader classLoader, String className) { 13 | Set methods = new HashSet(); 14 | // Class clazz = getClass(classLoader, className); 15 | // if (clazz != null) { 16 | // Method[] methodsArray = clazz.getMethods(); 17 | // for (Method method : methodsArray) { 18 | // methods.add(method.getName()); 19 | // } 20 | // } 21 | return methods; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod147.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.concurrent.ExecutionException; 6 | import java.util.concurrent.FutureTask; 7 | 8 | public class GenerateMethod147 extends GenerateMethodBase { 9 | /** 10 | * Returns the pid of the task 11 | */ 12 | @Override 13 | public String getPid(FutureTask t) { 14 | try { 15 | return t.get().toString(); 16 | } catch (InterruptedException e) { 17 | e.printStackTrace(); 18 | } catch (ExecutionException e) { 19 | e.printStackTrace(); 20 | } 21 | return ""; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod148.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod148 extends GenerateMethodBase { 8 | /** 9 | * Swaps the elements at the specified positions in the specified list. (If the specified positions are equal, invoking this method leaves the list unchanged.) 10 | */ 11 | @Override 12 | public void swap(List list, int i, int j) { 13 | E temp = list.get(i); 14 | list.set(i, list.get(j)); 15 | list.set(j, temp); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod149.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.*; 6 | 7 | public class GenerateMethod149 extends GenerateMethodBase { 8 | /** 9 | * Get the radian between current line(determined by point A and B) and horizontal line. 10 | */ 11 | @Override 12 | public float getRadian(Point A, Point B) { 13 | float radian = (float) (Math.atan2(B.y - A.y, B.x - A.x)); 14 | return radian; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod15.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.*; 6 | 7 | public class GenerateMethod15 extends GenerateMethodBase { 8 | /** 9 | * Copy a file from source path to destination path 10 | */ 11 | public void copyFile(String sourcePath, String destPath) { 12 | try { 13 | File destFile = new File(destPath); 14 | destFile.createNewFile(); 15 | BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destPath, true))); 16 | out.write("abc"); 17 | out.close(); 18 | } catch (IOException e) { 19 | 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod151.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod151 extends GenerateMethodBase { 6 | /** 7 | * Converts from an int array to an Integer array. 8 | */ 9 | @Override 10 | public Integer[] asObjectArray(int[] array) { 11 | Integer[] result = new Integer[array.length]; 12 | for (int i = 0; i < array.length; i++) { 13 | result[i] = array[i]; 14 | } 15 | return result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod153.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod153 extends GenerateMethodBase { 6 | /** 7 | * 计算 C2 = M xor t 8 | */ 9 | @Override 10 | public byte[] calculateC2(byte[] m, byte[] t) { 11 | byte[] c2 = new byte[m.length]; 12 | for (int i = 0; i < m.length; i++) { 13 | c2[i] = (byte) (m[i] ^ t[i]); 14 | } 15 | return c2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod154.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.net.URL; 6 | 7 | 8 | public class GenerateMethod154 extends GenerateMethodBase { 9 | /** 10 | * 获取资源文件的url 11 | */ 12 | public URL getUrlFile(String fileName) { 13 | return getClass().getResource(fileName); 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod156.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod156 extends GenerateMethodBase { 6 | /** 7 | * Adds a given vector (array) to another one. * Every element of the second array (missing element is treated to be zero) is added to the corresponding element (if not missing) of the first array. 8 | */ 9 | public void addTo(float[] arrayA, float[] arrayB) { 10 | for (int i = 0; i < arrayA.length; i++) { 11 | arrayA[i] += arrayB[i]; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod157.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod157 extends GenerateMethodBase { 6 | /** 7 | * Searches backward for value in a given array,not found return -1 8 | */ 9 | public int lastIndexOf(float value, float[] array) { 10 | for (int i = array.length - 1; i >= 0; i--) { 11 | if (array[i] == value) { 12 | return i; 13 | } 14 | } 15 | return -1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod16.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod16 extends GenerateMethodBase { 6 | /** 7 | * Get a hashCode for the real vector. All NaN values have the same hash code. 8 | */ 9 | public int hashCode(double[] vector) { 10 | int hash = 0; 11 | for (int i = 0; i < vector.length; i++) { 12 | if (Double.isNaN(vector[i])) { 13 | hash = hash * 31 + i; 14 | } else { 15 | hash = hash * 31 + (int) (vector[i] * 1000); 16 | } 17 | } 18 | return hash; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod161.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.Point; 6 | import java.util.List; 7 | 8 | public class GenerateMethod161 extends GenerateMethodBase { 9 | /** 10 | * Returns the geometric center of this sequence of points 11 | */ 12 | public Point getCenter(List points) { 13 | if (points == null || points.size() == 0) { 14 | return null; 15 | } 16 | int x = 0; 17 | int y = 0; 18 | for (Point point : points) { 19 | x += point.x; 20 | y += point.y; 21 | } 22 | return new Point(x / points.size(), y / points.size()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod162.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod162 extends GenerateMethodBase { 6 | /** 7 | * 括号匹配检测. 8 | */ 9 | public boolean checkbracket(String str) { 10 | int left = 0; 11 | int right = 0; 12 | for (int i = 0; i < str.length(); i++) { 13 | if (str.charAt(i) == '(') { 14 | left++; 15 | } else if (str.charAt(i) == ')') { 16 | right++; 17 | } 18 | } 19 | return left == right; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod165.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod165 extends GenerateMethodBase { 6 | /** 7 | * Decode base64 string to bytes 8 | */ 9 | public byte[] base64decode(String base64string) { 10 | return java.util.Base64.getDecoder().decode(base64string); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod166.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.reflect.Field; 6 | 7 | public class GenerateMethod166 extends GenerateMethodBase { 8 | /** 9 | * 通过反射为对象的对应字段注入值 10 | */ 11 | public T initByReflect(String name, String value, T t) throws Exception { 12 | Field field = t.getClass().getDeclaredField(name); 13 | field.setAccessible(true); 14 | field.set(t, value); 15 | return t; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod167.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class GenerateMethod167 extends GenerateMethodBase { 9 | /** 10 | * 将数组转为 List 11 | */ 12 | public List array2List(T[] array) { 13 | List list = new ArrayList(); 14 | for (T t : array) { 15 | list.add(t); 16 | } 17 | return list; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod168.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class GenerateMethod168 extends GenerateMethodBase { 9 | /** 10 | * 获取过去7天的时期(包括今天),格式为yymmdd 11 | */ 12 | public List getWeekDate() { 13 | List list = new ArrayList<>(); 14 | // for (int i = 0; i < 7; i++) { 15 | // list.add(getDate(i)); 16 | // } 17 | return list; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod169.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public class GenerateMethod169 extends GenerateMethodBase { 8 | /** 9 | * Returns the total number of bytes remaining in the buffer array. 10 | */ 11 | public long remaining(ByteBuffer[] buffers) { 12 | long remaining = 0; 13 | for (ByteBuffer buffer : buffers) { 14 | remaining += buffer.remaining(); 15 | } 16 | return remaining; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod17.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | 6 | import java.nio.charset.Charset; 7 | 8 | public class GenerateMethod17 extends GenerateMethodBase { 9 | /** 10 | * Parses character set name to Charset object 11 | */ 12 | public Charset charsetForName(String charsetName) { 13 | return Charset.forName(charsetName); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod170.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod170 extends GenerateMethodBase { 6 | /** 7 | * 返回y年m月d日对应的农历.返回格式为某年某月某日 ? 8 | */ 9 | public String getLunarDate(int year_log, int month_log, int day_log) { 10 | return ""; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod171.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod171 extends GenerateMethodBase { 6 | /** 7 | * 去掉浮点数多余的0 8 | */ 9 | public String rvZeroAndDot(String s) { 10 | String result = s; 11 | if (s.contains(".")) { 12 | int index = s.indexOf("."); 13 | String temp = s.substring(index + 1); 14 | if (temp.equals("0")) { 15 | result = s.substring(0, index); 16 | } 17 | } 18 | return result; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod173.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | 7 | public class GenerateMethod173 extends GenerateMethodBase { 8 | /** 9 | * Get the extension of a file. Return a null string if there is no extension. 10 | */ 11 | public String getFileExtension(File file) { 12 | String fileName = file.getName(); 13 | if (fileName.lastIndexOf(".") == -1) { 14 | return null; 15 | } else { 16 | return fileName.substring(fileName.lastIndexOf(".") + 1); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod174.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod174 extends GenerateMethodBase { 6 | /** 7 | * 判定一个字符串是不是整数 8 | */ 9 | public boolean isInteger(String numberString) { 10 | try { 11 | Integer.parseInt(numberString); 12 | return true; 13 | } catch (NumberFormatException e) { 14 | return false; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod176.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod176 extends GenerateMethodBase { 6 | /** 7 | * Returns true if the bit at the given position is 1 and false otherwise. 8 | */ 9 | @Override 10 | public boolean getBinaryState(int targetInteger, int position){ 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod177.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod177 extends GenerateMethodBase { 6 | /** 7 | * 获取当前进程的ID 8 | */ 9 | @Override 10 | public String getProcessId() { 11 | return ""; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod178.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod178 extends GenerateMethodBase { 6 | /** 7 | * Handles comparison between version numbers (the right way(TM)),bigger return 1 ,smaller return -1 and equals return 0. Examples of version strings: 1.6.7, 1.2_b10 8 | */ 9 | @Override 10 | public int versionCompare(String v1, String v2) { 11 | return 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod179.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod179 extends GenerateMethodBase { 8 | /** 9 | * 在map中,如果key存在,则value相加;如果key 不存在,增加新的key,value 10 | */ 11 | @Override 12 | public Long incrBy(Map valMap, String key, Long integer) { 13 | if (valMap.containsKey(key)){ 14 | valMap.put(key,valMap.get(key)+integer); 15 | }else { 16 | valMap.put(key,integer); 17 | } 18 | return valMap.get(key); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod18.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.*; 6 | 7 | public class GenerateMethod18 extends GenerateMethodBase { 8 | /** 9 | * Reads up to len bytes of data from this input stream into an array of bytes 10 | */ 11 | public byte[] readBytes(InputStream in, int len) { 12 | byte[] bytes = new byte[len]; 13 | int read = 0; 14 | try { 15 | while (read < len) { 16 | int count = in.read(bytes, read, len - read); 17 | if (count < 0) { 18 | break; 19 | } 20 | read += count; 21 | } 22 | } catch (Exception e) { 23 | e.printStackTrace(); 24 | } 25 | return bytes; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod180.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod180 extends GenerateMethodBase { 6 | /** 7 | * Check if a string is binary, which is composed of 0/1, and string length is multiple of 8. 8 | */ 9 | @Override 10 | public boolean isBin(String bin) { 11 | if (bin.length() % 8 != 0) { 12 | return false; 13 | } 14 | for (int i = 0; i < bin.length(); i++) { 15 | if (bin.charAt(i) != '0' && bin.charAt(i) != '1') { 16 | return false; 17 | } 18 | } 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod181.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod181 extends GenerateMethodBase { 8 | /** 9 | * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. 如无法找到, 返回Object.class. 10 | */ 11 | public List getClassGenricType(Class clazz){ 12 | // return getClassGenricType(clazz, 0); 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod182.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod182 extends GenerateMethodBase { 6 | /** 7 | * 滤掉词串中的空格、标点符号 8 | */ 9 | @Override 10 | public String[] filter(String[] word_list) { 11 | if (word_list == null || word_list.length == 0) { 12 | return null; 13 | } 14 | 15 | String[] result = new String[word_list.length]; 16 | int index = 0; 17 | for (String word : word_list) { 18 | if (word.length() == 0) { 19 | continue; 20 | } 21 | 22 | result[index++] = word.replaceAll("[\\s\\pP\\p{Punct}]", ""); 23 | } 24 | 25 | return result; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod183.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.math.BigDecimal; 6 | 7 | public class GenerateMethod183 extends GenerateMethodBase { 8 | /** 9 | * BigDecimal加法运算 10 | */ 11 | @Override 12 | public BigDecimal add(BigDecimal aVal, BigDecimal bVal) { 13 | return aVal.add(bVal); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod186.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod186 extends GenerateMethodBase { 6 | /** 7 | * Returns whether or no the JDK version is 1.7u40 and above. 8 | */ 9 | @Override 10 | public boolean isJdk7u40Above() { 11 | return false; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod19.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class GenerateMethod19 extends GenerateMethodBase { 9 | /** 10 | * Parses query string to Map from an url. 11 | */ 12 | public Map parseQueryString(String queryString) { 13 | Map map = new HashMap(); 14 | String[] pairs = queryString.split("&"); 15 | for (String pair : pairs) { 16 | String[] keyValue = pair.split("="); 17 | map.put(keyValue[0], keyValue[1]); 18 | } 19 | return map; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod20.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod20 extends GenerateMethodBase { 6 | /** 7 | * Returns the value of an array by index, or null if the array has no value at that index. 8 | */ 9 | public Object get(Object[] array, int index) { 10 | return array[index]; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod21.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod21 extends GenerateMethodBase { 8 | /** 9 | * Set the additional (undeclared) property with the specified name and value. If the property does not already exist, create it otherwise replace it. 10 | */ 11 | public void putAdditionalProperty(String key, Object value, Map additionalProperties) { 12 | additionalProperties.put(key, value); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod22.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod22 extends GenerateMethodBase { 6 | /** 7 | * Read the base64 encoded image data from a JPEG image. 8 | */ 9 | public String readImageData(String filename) { 10 | // TODO 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod23.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod23 extends GenerateMethodBase { 6 | /** 7 | * Returns the distance for the two given point 8 | */ 9 | public float distance(float x0, float y0, float x1, float y1) { 10 | return (float) Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod24.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.util.Collection; 7 | 8 | public class GenerateMethod24 extends GenerateMethodBase { 9 | /** 10 | * Writes a collection of Strings to a File, overwriting any previous file contents. Each String is converted into a line in the File. 11 | */ 12 | public void writeFile(Collection lines, File file) { 13 | try { 14 | if (file.exists()) { 15 | file.delete(); 16 | } 17 | file.createNewFile(); 18 | java.io.FileWriter fw = new java.io.FileWriter(file); 19 | for (String line : lines) { 20 | fw.write(line + "\n"); 21 | } 22 | fw.close(); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod25.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod25 extends GenerateMethodBase { 6 | /** 7 | * Generate a hex string for the specified bytes. 8 | */ 9 | public final String toHex(byte[] byteArr) { 10 | StringBuilder sb = new StringBuilder(); 11 | for (byte b : byteArr) { 12 | sb.append(String.format("%02x", b)); 13 | } 14 | return sb.toString(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod26.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod26 extends GenerateMethodBase { 6 | /** 7 | * 获取相应文件filepath的input stream 8 | */ 9 | public java.io.InputStream getInputStream(String filepath) { 10 | // TODO 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod27.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.lang.annotation.Annotation; 6 | 7 | public class GenerateMethod27 extends GenerateMethodBase { 8 | /** 9 | * 获取类上具有指定注解的接口的名称,如果有多个,则以第一个为准 找不到符合条件的接口则返回 clazz 类的名称 10 | */ 11 | public String getInterfaceName(Class clazz, Class annotation) { 12 | for (Class c : clazz.getInterfaces()) { 13 | if (c.isAnnotationPresent(annotation)) { 14 | return c.getName(); 15 | } 16 | } 17 | return clazz.getName(); 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod29.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod29 extends GenerateMethodBase { 6 | /** 7 | * This returns the euclidean distance of two vectors sum(i=1,n) (q_i - p_i)^2 8 | */ 9 | public double euclideanDistance(double[] p, double[] q) { 10 | double sum = 0; 11 | for (int i = 0; i < p.length; i++) { 12 | sum += (q[i] - p[i]) * (q[i] - p[i]); 13 | } 14 | return Math.sqrt(sum); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod30.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod30 extends GenerateMethodBase { 8 | /** 9 | * Returns the entry associated with the specified key in map. 10 | */ 11 | public Map.Entry getEntry(Map map, K key) 12 | { 13 | for (Map.Entry e : map.entrySet()) 14 | { 15 | if (e.getKey().equals(key)) 16 | { 17 | return e; 18 | } 19 | } 20 | return null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod31.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod31 extends GenerateMethodBase { 6 | /** 7 | * Returns the index of the first occurrence of the specified element in this list, returns -1 if the element is not found 8 | */ 9 | public int indexOf(int[] array, int element) 10 | { 11 | for (int i = 0; i < array.length; i++) 12 | { 13 | if (array[i] == element) 14 | { 15 | return i; 16 | } 17 | } 18 | return -1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod32.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod32 extends GenerateMethodBase { 6 | /** 7 | * Returns the minimum value in an array. 8 | */ 9 | public int min(int[] array) 10 | { 11 | int min = array[0]; 12 | for (int i = 1; i < array.length; i++) 13 | { 14 | if (array[i] < min) 15 | { 16 | min = array[i]; 17 | } 18 | } 19 | return min; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod33.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod33 extends GenerateMethodBase { 6 | /** 7 | * Returns the sum of logarithms, which is Sum( Log(x[i]) ). 8 | */ 9 | public double logSum(double[] x) { 10 | double sum = 0; 11 | for (double xi : x) { 12 | sum += Math.log(xi); 13 | } 14 | return sum; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod34.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod34 extends GenerateMethodBase { 6 | /** 7 | * Do a simple bubble sort to sort the server ids in ascending order. 8 | */ 9 | public void sortServers(int[] serverIds) 10 | { 11 | for (int i = 0; i < serverIds.length; i++) 12 | { 13 | for (int j = i + 1; j < serverIds.length; j++) 14 | { 15 | if (serverIds[i] > serverIds[j]) 16 | { 17 | int temp = serverIds[i]; 18 | serverIds[i] = serverIds[j]; 19 | serverIds[j] = temp; 20 | } 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod35.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod35 extends GenerateMethodBase { 6 | /** 7 | * Ensure that an object reference passed as a parameter to the calling method is not null. 8 | */ 9 | public void ensureNotNull(Object obj) 10 | { 11 | if (obj == null) 12 | { 13 | throw new NullPointerException(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod36.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod36 extends GenerateMethodBase { 6 | /** 7 | * Extract the filename from the given path. 8 | */ 9 | public String extractFileName(String path) { 10 | return path.substring(path.lastIndexOf("/") + 1); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod37.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod37 extends GenerateMethodBase { 6 | /** 7 | * Fill 1D matrix with random numbers. 8 | */ 9 | public void fillMatrix_1D(double[] m) { 10 | for (int i = 0; i < m.length; i++) { 11 | m[i] = Math.random(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod38.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod38 extends GenerateMethodBase { 6 | /** 7 | * Find the occurence of the given key in the given array. Linear search, worst case running time is O(n). 8 | */ 9 | public int linearSearch(int[] arr, int key) { 10 | for (int i = 0; i < arr.length; i++) { 11 | if (arr[i] == key) { 12 | return i; 13 | } 14 | } 15 | return -1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod39.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod39 extends GenerateMethodBase { 6 | /** 7 | * Generate a not existing temporary file in specified dir 8 | */ 9 | public String generateTempFile(String dir) { 10 | String fileName = ""; 11 | try { 12 | fileName = java.io.File.createTempFile("temp", ".tmp", new java.io.File(dir)).getAbsolutePath(); 13 | } catch (java.io.IOException e) { 14 | // e.printStackTrace(); 15 | } 16 | return fileName; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod4.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.Reader; 6 | 7 | public class GenerateMethod4 extends GenerateMethodBase { 8 | /** 9 | * Close Reader. If object is null it is ignored 10 | */ 11 | public void close(Reader reader) { 12 | if (reader != null) { 13 | try { 14 | reader.close(); 15 | } catch (Exception e) { 16 | // ignore 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod40.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod40 extends GenerateMethodBase { 6 | /** 7 | * Get one character of index i from a given string buffer. 8 | */ 9 | public char getChar(StringBuffer sb, int i){ 10 | return sb.charAt(i); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod41.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class GenerateMethod41 extends GenerateMethodBase { 9 | /** 10 | * 将map中所有的key转为大写 11 | */ 12 | public Map getAllUpperCase(Map map) { 13 | Map result = new HashMap<>(); 14 | for (Map.Entry entry : map.entrySet()) { 15 | result.put(entry.getKey().toUpperCase(), entry.getValue()); 16 | } 17 | return result; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod42.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod42 extends GenerateMethodBase { 6 | /** 7 | * 得到距离当前时间前一年的时间 8 | */ 9 | public String getLastYearDate() { 10 | java.util.Calendar cal = java.util.Calendar.getInstance(); 11 | cal.add(java.util.Calendar.YEAR, -1); 12 | return new java.text.SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod43.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod43 extends GenerateMethodBase { 6 | /** 7 | * 更新url中的参数(保证参数不重复) 8 | */ 9 | public String updateUrl(String url, String key, String value) { 10 | if (url.contains("?")) { 11 | url += "&"; 12 | } else { 13 | url += "?"; 14 | } 15 | url += key + "=" + value; 16 | return url; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod44.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod44 extends GenerateMethodBase { 8 | /** 9 | * 移除 map 中的 null 或者 空字符串 10 | */ 11 | public void removeNullValue(Map map) { 12 | for (Map.Entry entry : map.entrySet()) { 13 | if (entry.getValue() == null || entry.getValue().equals("")) { 14 | map.remove(entry.getKey()); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod45.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Date; 6 | 7 | public class GenerateMethod45 extends GenerateMethodBase { 8 | /** 9 | * 获取某个时间data的年份 10 | */ 11 | public int getYear(Date date) { 12 | return date.getYear(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod46.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod46 extends GenerateMethodBase { 6 | /** 7 | * Element-by-element matrix multiplication in place, A = A*B 8 | */ 9 | public void matrixMultiply(double[][] A, double[][] B) { 10 | // TODO 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod48.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Collection; 6 | import java.util.Set; 7 | 8 | public class GenerateMethod48 extends GenerateMethodBase { 9 | /** 10 | * Adds all of the elements in collection to the Set. 11 | */ 12 | public void addAll(Set set, Collection collection) 13 | { 14 | for (Integer i : collection) 15 | { 16 | set.add(i); 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod49.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod49 extends GenerateMethodBase { 6 | /** 7 | * Helper function to convert a long number into a byte array (least significant byte first). 8 | */ 9 | public byte[] longToBytes(long x) { 10 | byte[] bytes = new byte[8]; 11 | for (int i = 7; i >= 0; i--) { 12 | bytes[i] = (byte) (x & 0xff); 13 | x >>= 8; 14 | } 15 | return bytes; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod5.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod5 extends GenerateMethodBase { 6 | /** 7 | * max() that works on three integers. Like many of the other max() functions in this class 8 | */ 9 | public float max(float a, float b, float c) { 10 | float max = a; 11 | if (b > max) { 12 | max = b; 13 | } 14 | if (c > max) { 15 | max = c; 16 | } 17 | return max; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod50.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod50 extends GenerateMethodBase { 6 | /** 7 | * 将byte数组转化为16进制字符串 8 | */ 9 | public String bytesToHexString(byte[] src) { 10 | StringBuilder stringBuilder = new StringBuilder(""); 11 | if (src == null || src.length <= 0) { 12 | return null; 13 | } 14 | for (int i = 0; i < src.length; i++) { 15 | int v = src[i] & 0xFF; 16 | String hv = Integer.toHexString(v); 17 | if (hv.length() < 2) { 18 | stringBuilder.append(0); 19 | } 20 | stringBuilder.append(hv); 21 | } 22 | return stringBuilder.toString(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod51.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod51 extends GenerateMethodBase { 6 | /** 7 | * Returns a hash code value for this bit array. 8 | */ 9 | public int hashCode(byte[] byteArray) { 10 | int hash = 0; 11 | for (int i = 0; i < byteArray.length; i++) { 12 | hash = 31 * hash + byteArray[i]; 13 | } 14 | return hash; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod52.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Map; 6 | 7 | public class GenerateMethod52 extends GenerateMethodBase { 8 | /** 9 | * Removes the entry with the specified key from this map if present. 10 | */ 11 | public void remove(Map mapObj, Integer key) { 12 | mapObj.remove(key); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod53.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod53 extends GenerateMethodBase { 6 | /** 7 | * Convert a primitive input array into its object array version (e.g. from int[] to Integer[]). 8 | */ 9 | public Integer[] toObjectArray(int[] array) { 10 | return null; 11 | } 12 | 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod55.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod55 extends GenerateMethodBase { 6 | /** 7 | * 判断字符串是否只含字母和数字 8 | */ 9 | public boolean isLetterOrDigit(String str) { 10 | return str.matches("^[a-zA-Z0-9]+$"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod56.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod56 extends GenerateMethodBase { 6 | /** 7 | * 判断是否只含字母 8 | */ 9 | public boolean isLetter(char c) { 10 | return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod57.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod57 extends GenerateMethodBase { 6 | /** 7 | * Join 2 path elements if path separator not present at the end of first path element,else return the first element. 8 | */ 9 | public String joinPath(String path1, String path2) { 10 | // TODO 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod58.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod58 extends GenerateMethodBase { 6 | /** 7 | * Converts an int into an array of byte using the default (little endian, Lsb0) byte and bit ordering. 8 | */ 9 | public byte[] intToByteArray(int value){ 10 | return new byte[]{ 11 | (byte) (value >>> 24), 12 | (byte) (value >>> 16), 13 | (byte) (value >>> 8), 14 | (byte) value}; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod6.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod6 extends GenerateMethodBase { 6 | /** 7 | * put a short value into a byte array with specific offset 8 | */ 9 | public void putShort(byte[] data, short value, int offset) { 10 | data[offset] = (byte) (value >> 8); 11 | data[offset + 1] = (byte) value; 12 | } 13 | 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod60.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod60 extends GenerateMethodBase { 6 | /** 7 | * convert byte array to a hex string 8 | */ 9 | public String bytesToHex(byte[] bytes) { 10 | StringBuilder sb = new StringBuilder(); 11 | for (byte b : bytes) { 12 | sb.append(String.format("%02x", b)); 13 | } 14 | return sb.toString(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod62.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod62 extends GenerateMethodBase { 6 | /** 7 | * Calculates combinatorial number C(n,m). 8 | */ 9 | public int combinatorial(int n, int m) { 10 | if (n < 0 || m < 0 || m > n) { 11 | return 0; 12 | } 13 | if (m == 0 || m == n) { 14 | return 1; 15 | } 16 | return combinatorial(n - 1, m - 1) + combinatorial(n - 1, m); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod63.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod63 extends GenerateMethodBase { 6 | /** 7 | * 检验用户名是否合法,只能包括a-z,A-Z,0-9和下划线_,不能以下划线结尾 用户名有最小长度和最大长度限制,比如用户名必须是4-20位 8 | */ 9 | public boolean checkUsername(String username) { 10 | if (username.length() < 4 || username.length() > 20) { 11 | return false; 12 | } 13 | for (int i = 0; i < username.length(); i++) { 14 | char c = username.charAt(i); 15 | if (c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) { 16 | return false; 17 | } 18 | } 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod64.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod64 extends GenerateMethodBase { 6 | /** 7 | * 得到现在时间 8 | */ 9 | public String getStringToday(String format) 10 | { 11 | java.util.Date today = new java.util.Date(); 12 | java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(format); 13 | String dateString = formatter.format(today); 14 | return dateString; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod65.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Date; 6 | 7 | public class GenerateMethod65 extends GenerateMethodBase { 8 | /** 9 | * return the last day of the date's month of specified string value in format: yyyy-MM 10 | */ 11 | public Date getMonthLastDay(String dateString) { 12 | // Date date = Date.parse(dateString); 13 | // return getMonthLastDay(date); 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod66.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class GenerateMethod66 extends GenerateMethodBase { 8 | /** 9 | * Merges the given two lists to a new list, but eliminating duplicates elements. 10 | */ 11 | public ArrayList merge(ArrayList list1, ArrayList list2) { 12 | ArrayList result = new ArrayList<>(); 13 | for (T t : list1) { 14 | if (!result.contains(t)) { 15 | result.add(t); 16 | } 17 | } 18 | for (T t : list2) { 19 | if (!result.contains(t)) { 20 | result.add(t); 21 | } 22 | } 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod67.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod67 extends GenerateMethodBase { 6 | /** 7 | * Multiplies the vector by the transpose of the given matrix. 8 | */ 9 | public double[] multiplyTranspose(double[] vector, double[][] matrix) { 10 | double[] result = new double[vector.length]; 11 | for (int i = 0; i < vector.length; i++) { 12 | for (int j = 0; j < vector.length; j++) { 13 | result[i] += vector[j] * matrix[j][i]; 14 | } 15 | } 16 | return result; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod68.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class GenerateMethod68 extends GenerateMethodBase { 8 | /** 9 | * Removes and returns last element in list, return null if empty. 10 | */ 11 | public String removeLast(ArrayList list) { 12 | if (list.isEmpty()) { 13 | return null; 14 | } 15 | return list.remove(list.size() - 1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod69.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.LinkedList; 6 | 7 | public class GenerateMethod69 extends GenerateMethodBase { 8 | /** 9 | * Returns the largest value in linked list. 10 | */ 11 | public int getMax(LinkedList list) { 12 | int max = list.get(0); 13 | for (int i = 1; i < list.size(); i++) { 14 | if (list.get(i) > max) { 15 | max = list.get(i); 16 | } 17 | } 18 | return max; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod7.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.InputStream; 6 | import java.net.URL; 7 | import java.util.Properties; 8 | 9 | public class GenerateMethod7 extends GenerateMethodBase { 10 | /** 11 | * 从 http 服务拉取配置文件并解析为Properties 对象 12 | */ 13 | 14 | public Properties getProperties(String url) { 15 | Properties properties = new Properties(); 16 | try { 17 | URL u = new URL(url); 18 | InputStream is = u.openStream(); 19 | properties.load(is); 20 | is.close(); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | return properties; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod70.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Calendar; 6 | 7 | public class GenerateMethod70 extends GenerateMethodBase { 8 | /** 9 | * Calculate the elapsed time between two times specified in milliseconds. 10 | */ 11 | public long elapsedTime(Calendar start, Calendar end) { 12 | return end.getTimeInMillis() - start.getTimeInMillis(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod72.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod72 extends GenerateMethodBase { 6 | /** 7 | * Create an instance of a clazz using the current thread context ClassLoader. 8 | */ 9 | public T newInstance(Class clazz) { 10 | try { 11 | return clazz.newInstance(); 12 | } catch (InstantiationException | IllegalAccessException e) { 13 | throw new RuntimeException(e); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod73.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod73 extends GenerateMethodBase { 8 | /** 9 | * Delete data from start until end index (end inclusive) of a object List. 10 | */ 11 | public void delete(List list, int start, int end) { 12 | for (int i = start; i <= end; i++) { 13 | list.remove(start); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod78.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod78 extends GenerateMethodBase { 6 | /** 7 | * 用str2替换字符串str中第一个出现的str1 8 | */ 9 | public String replaceFirst(String str, String str1, String str2) { 10 | int index = str.indexOf(str1); 11 | if (index == -1) { 12 | return str; 13 | } 14 | return str.substring(0, index) + str2 + str.substring(index + str1.length()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod8.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod8 extends GenerateMethodBase { 6 | 7 | /** 8 | * 给一个数组,找出最大值并且返回。 9 | */ 10 | public int findMaxNumber(int[] nums) { 11 | int max = nums[0]; 12 | for (int i = 1; i < nums.length; i++) { 13 | if (nums[i] > max) { 14 | max = nums[i]; 15 | } 16 | } 17 | return max; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod80.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod80 extends GenerateMethodBase { 6 | /** 7 | * 随机生成[origin, bound)范围之内的一个int值 8 | */ 9 | public int randomInt(int origin, int bound) { 10 | return (int) (Math.random() * (bound - origin) + origin); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod81.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | 8 | public class GenerateMethod81 extends GenerateMethodBase { 9 | /** 10 | * 上传一个文件至指定路径pathname下 11 | */ 12 | public void uploadFile(String pathname, String filename) { 13 | try { 14 | File file = new File(pathname); 15 | if (!file.exists()) { 16 | file.mkdirs(); 17 | } 18 | FileOutputStream fos = new FileOutputStream(pathname + filename); 19 | fos.write(filename.getBytes()); 20 | fos.close(); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod83.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.List; 6 | 7 | public class GenerateMethod83 extends GenerateMethodBase { 8 | /** 9 | * Returns a new, immutable collection containing the names of all entities within the directory denoted by the current path 10 | */ 11 | public List getFiles(String dir) { 12 | return null; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod84.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.awt.*; 6 | 7 | public class GenerateMethod84 extends GenerateMethodBase { 8 | /** 9 | * Rotate this a two-dimensional point around Y axis with the given angle in radians. 10 | */ 11 | public Point rotateY(double angle, Point point) { 12 | double x = point.x * Math.cos(angle) - point.y * Math.sin(angle); 13 | double y = point.x * Math.sin(angle) + point.y * Math.cos(angle); 14 | return new Point((int) x, (int) y); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod85.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod85 extends GenerateMethodBase { 6 | /** 7 | * If the string passed in is not blank or null and did not end with the trailing value, then appended the trailing value to it and return the result 8 | */ 9 | public String appendTrailing(String str, String trailing) { 10 | if (str == null || str.isEmpty()) { 11 | return str; 12 | } 13 | if (str.endsWith(trailing)) { 14 | return str; 15 | } 16 | return str + trailing; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod86.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.Collection; 6 | 7 | public class GenerateMethod86 extends GenerateMethodBase { 8 | /** 9 | * Returns true if the collection contains an element for the key. 10 | */ 11 | public boolean containsKey(Collection collection, String key) { 12 | for (String k : collection) { 13 | if (k.equals(key)) { 14 | return true; 15 | } 16 | } 17 | return false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod87.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod87 extends GenerateMethodBase { 6 | /** 7 | * Returns true if the given object is an instance of the class or interface specified. 8 | */ 9 | public boolean isInstanceOf(Object object, Class type) { 10 | return type.isInstance(object); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod88.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod88 extends GenerateMethodBase { 6 | /** 7 | * 将16进制字符串转10进制 8 | */ 9 | public int hexStringToInt(String hexString) { 10 | int result = 0; 11 | for (int i = 0; i < hexString.length(); i++) { 12 | char c = hexString.charAt(i); 13 | int value = 0; 14 | if (c >= '0' && c <= '9') { 15 | value = c - '0'; 16 | } else if (c >= 'a' && c <= 'f') { 17 | value = c - 'a' + 10; 18 | } else if (c >= 'A' && c <= 'F') { 19 | value = c - 'A' + 10; 20 | } 21 | result = result * 16 + value; 22 | } 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod89.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod89 extends GenerateMethodBase { 6 | /** 7 | * Add two integers, checking for overflow. 8 | */ 9 | public boolean checkOverflow(int x, int y) { 10 | long s = (long) x + (long) y; 11 | 12 | if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) { 13 | return true; 14 | } 15 | 16 | return false; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod9.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.text.DateFormat; 6 | import java.util.Date; 7 | 8 | public class GenerateMethod9 extends GenerateMethodBase { 9 | /** 10 | * 将 Date 类型转为时间字符串,格式为 format 11 | */ 12 | public String date2String(final Date date, final DateFormat format) { 13 | return format.format(date); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod90.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | import java.util.HashSet; 6 | import java.util.Map; 7 | 8 | public class GenerateMethod90 extends GenerateMethodBase { 9 | /** 10 | * Add the value to the HashSet given by map.get(key), creating a new HashSet if the HashSet is null 11 | */ 12 | public void addToSet(Map> map, String key, Integer value) { 13 | HashSet set = map.get(key); 14 | if (set == null) { 15 | set = new HashSet<>(); 16 | map.put(key, set); 17 | } 18 | set.add(value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod91.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod91 extends GenerateMethodBase { 6 | /** 7 | * Calculate and return the average of the two values rounded DOWN. 8 | */ 9 | public int average(int a, int b) { 10 | return (a + b) / 2; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod92.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod92 extends GenerateMethodBase { 6 | /** 7 | * Check if #MIN_VALUE <= value <= #MAX_VALUE and if not an IllegalArgumentException is thrown. 8 | */ 9 | public void checkRange(int value, int min, int max) { 10 | if (value < min || value > max) { 11 | throw new IllegalArgumentException("Value out of range: " + value); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod93.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod93 extends GenerateMethodBase { 6 | /** 7 | * Check whether the String is a valid Java number 8 | */ 9 | public boolean isNumber(String str) { 10 | if (str == null || str.length() == 0) { 11 | return false; 12 | } 13 | int i = 0; 14 | if (str.charAt(0) == '-') { 15 | i = 1; 16 | } 17 | for (; i < str.length(); i++) { 18 | char c = str.charAt(i); 19 | if (c < '0' || c > '9') { 20 | return false; 21 | } 22 | } 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod94.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod94 extends GenerateMethodBase { 6 | /** 7 | * Choose a pseudo-random element from the specified array. 8 | */ 9 | public int random(int[] array) { 10 | return array[(int) (Math.random() * array.length)]; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod95.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod95 extends GenerateMethodBase { 6 | /** 7 | * Compare two java objects for equality. 8 | */ 9 | public boolean equals(Object o1, Object o2) { 10 | if (o1 == null) { 11 | return o2 == null; 12 | } 13 | return o1.equals(o2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod96.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod96 extends GenerateMethodBase { 6 | /** 7 | * Compute the product of this matrix and the given column vector. 8 | */ 9 | public double[] product(double[] columnVector,double[][] matrix) { 10 | double[] result=new double[matrix.length]; 11 | for (int i=0;i T[] concat(T[] a, T[] b) { 10 | T[] result = (T[]) new Object[a.length + b.length]; 11 | System.arraycopy(a, 0, result, 0, a.length); 12 | System.arraycopy(b, 0, result, a.length, b.length); 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/autoTest/generate/copilot/GenerateMethod99.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.autoTest.generate.copilot; 2 | 3 | import com.aixcode.autoTest.GenerateMethodBase; 4 | 5 | public class GenerateMethod99 extends GenerateMethodBase { 6 | /** 7 | * Convert a boolean value into a string. 8 | */ 9 | public String boolToString(boolean b) { 10 | return b ? "true" : "false"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/sampleHelper/Male.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.sampleHelper; 2 | 3 | public class Male extends Person { 4 | private String hobby; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/sampleHelper/Person.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.sampleHelper; 2 | 3 | public class Person { 4 | private T name; 5 | private M age; 6 | 7 | public T getName() { 8 | return name; 9 | } 10 | 11 | public void setName(T name) { 12 | this.name = name; 13 | } 14 | 15 | public M getAge() { 16 | return age; 17 | } 18 | 19 | public void setAge(M age) { 20 | this.age = age; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/sampleHelper/sample27/InterfaceWithAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.sampleHelper.sample27; 2 | 3 | import java.beans.JavaBean; 4 | 5 | @JavaBean 6 | public interface InterfaceWithAnnotation { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/aixcode/sampleHelper/sample27/TestFor27.java: -------------------------------------------------------------------------------- 1 | package com.aixcode.sampleHelper.sample27; 2 | 3 | public class TestFor27 implements InterfaceWithAnnotation { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/tempFile/copyFile.txt: -------------------------------------------------------------------------------- 1 | this is content -------------------------------------------------------------------------------- /src/main/resources/tempFile/sample173.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/sample173.txt -------------------------------------------------------------------------------- /src/main/resources/tempFile/tempFile116.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/tempFile116.txt -------------------------------------------------------------------------------- /src/main/resources/tempFile/test144/data144.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test144/data144.zip -------------------------------------------------------------------------------- /src/main/resources/tempFile/test144/data144.zip.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test144/data144.zip.bak -------------------------------------------------------------------------------- /src/main/resources/tempFile/test163/srcDir/dir1/dir2/file1.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test163/srcDir/dir1/dir2/file1.tmp -------------------------------------------------------------------------------- /src/main/resources/tempFile/test76/test1/BaseAbstractTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test76/test1/BaseAbstractTest.class -------------------------------------------------------------------------------- /src/main/resources/tempFile/test76/test2/2/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test76/test2/2/Constants.class -------------------------------------------------------------------------------- /src/main/resources/tempFile/test76/test2/BaseAbstractTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test76/test2/BaseAbstractTest.class -------------------------------------------------------------------------------- /src/main/resources/tempFile/test81/fromDir/file1.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixcoder-plugin/nl2code-dataset/4c2003d0a4274c8ceec5cd6149dcf445136e4141/src/main/resources/tempFile/test81/fromDir/file1.tmp --------------------------------------------------------------------------------