/** * To get all directories that satisfy the conditions in this directory * @param lucenefilepathregular Regular directory, such as/user/solrindex/regular expression * @return A catalog collection that satisfies regular expressions List*/ Public StaticList<string>Fetchdirbyregularlinux (String lucenefilepathregular) {List<String> list=NewArraylist<>(); //Split get home directory intlen= Lucenefilepathregular.lastindexof (etlconstants.linux_route_segment) +1; String Maindir=lucenefilepathregular.substring (0, Len); String Regular=lucenefilepathregular.substring (Len,lucenefilepathregular.length ()); File dir=NewFile (Maindir); if(Dir.exists () &&dir.isdirectory ()) {File [] arr=Dir.listfiles (); for(File file:arr) {if(File.exists () &&file.isdirectory ()) {String FileName=File.getname (); if(Matchstr (FileName, Regular)) {List.add (File.getabsolutepath ()+Solrutil.index_dir_suffix); } } } } if(List.size () >0) {Logger.info ("The SOLR directories to which they are matched are:"); for(String s:list) {logger.info (s); } }Else{logger.error ("Path {}, there is no directory that satisfies the regular: {} condition", dir, regular); } returnlist; }
/** * @Method Description: Matches the string by regular means * @param str * @param regular * @return*/ Public StaticBoolean matchstr (String str, string regular) {pattern pattern=Pattern.compile (Regular); Matcher Matcher=Pattern.matcher (str); returnmatcher.matches (); } /** * Base exponent * @param base * @param exponent * @return*/ Public Static intPowint Base,intexponent) { intresult=1; for(intI=0; i<exponent;i++) {result=result*Base; } returnresult; }
Public StaticFinal map<string, long> date_map =NewHashmap<string, long>() {{put ("Month", +* -* -*24L); Put (" Day", +* -* -*24L); Put ("Hour", +* -*60L); } };
/** * Convert string to specified number of digits size * insufficient, front supplemental Supplementvalue * exceeded, Iscutfront to true intercept front size bit * @param original * @p Aram Size * @param supplementvalue * @return*/ Public StaticString Supplementstringfront (string original,intsize,string Supplementvalue) { returnCutstring (Original,size,true, Supplementvalue,true); } /** * @param original * @param size * @param supplementvalue * @param front * @return*/ /** * Convert string to specified number of digits size * Insufficient, isfrontsupplement to true, front complement supplementvalue,isfrontsupplement false, back supplement Supplementvalu E * exceeds, Iscutfront is true to intercept the previous size bit, Iscutfront is false, intercept the size bit behind * @param original * @param size * @param ISFR Ontsupplement * @param supplementvalue * @param iscutfront * @return*/ Public StaticString Cutstring (string original,intSize,boolean isfrontsupplement,string Supplementvalue,boolean iscutfront) { intLength=original.length (); String result=NULL; if(length==size) {Result=original; }Else if(length<size) { if(isfrontsupplement) {result=supplementvalue+original; while(Result.length () <size) {Result=supplementvalue+result; } }Else{result=original+Supplementvalue; while(Result.length () <size) {Result=result+Supplementvalue; } } } //length>size Else{ if(iscutfront) {result=original.substring (0, size); }Else{result=original.substring (Original.length ()-size,original.length ()); } } returnresult; }
Java Common methods