Guest User

Untitled

a guest
May 22nd, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.49 KB | None | 0 0
  1.  
  2.  
  3.  
  4. public class name {
  5.    
  6.    
  7.    
  8.    
  9.    
  10.    
  11.    
  12.     name(String orgName) throws Exception
  13.     {this.orgName=orgName;
  14.      this.fullName=removeClanTag(orgName);
  15.      this.clanTag=generateClanTag(orgName);
  16.      this.longNick=generateLongNick(fullName);
  17.      this.shortNick=generateShortNick(fullName, this.longNick);}
  18.    
  19.     private String orgName;
  20.     public String getOrgName() {
  21.         return orgName;
  22.     }
  23.     public void setOrgName(String orgName) {
  24.         this.orgName = orgName;
  25.     }
  26.     public String getFullName() {
  27.         return fullName;
  28.     }
  29.     public void setFullName(String fullName) {
  30.         this.fullName = fullName;
  31.     }
  32.     public String getLongNick() {
  33.         return longNick;
  34.     }
  35.     public void setLongNick(String longNick) {
  36.         this.longNick = longNick;
  37.     }
  38.     public String getShortNick() {
  39.         return shortNick;
  40.     }
  41.     public void setShortNick(String shortNick) {
  42.         this.shortNick = shortNick;
  43.     }
  44.     public String getClanTag() {
  45.         return clanTag;
  46.     }
  47.     public void setClanTag(String clanTag) {
  48.         this.clanTag = clanTag;
  49.     }
  50.  
  51.     private String fullName;
  52.     private String longNick;
  53.     private String shortNick;
  54.     private String clanTag;
  55.  
  56.    
  57.    
  58.    
  59.     private String generateClanTag(String orgName)
  60.     {orgName=orgName.trim();
  61.     //find lastStartBrace
  62.     int lastOpenBraceFound=0;
  63.     int firstEndBraceFound=0;
  64.     boolean virginBool=true;
  65.  
  66.     for (int i=0;i<orgName.length();i++)
  67.     {char tempChar=orgName.charAt(i);
  68.     if (tempChar=='('||tempChar=='['||tempChar=='<'||tempChar=='{'||tempChar=='~')
  69.     {lastOpenBraceFound=i;  }
  70.     }
  71.     //find firstEndBrace
  72.     for (int i=0;i<orgName.length();i++)
  73.     {
  74.         char tempChar=orgName.charAt(i);
  75.         if (virginBool==true)
  76.         {  
  77.            
  78.            
  79.            
  80.             if (tempChar==')'||tempChar==']'||tempChar=='>'||tempChar=='}')
  81.             {firstEndBraceFound=i;
  82.             virginBool=false;}
  83.            
  84.         }  
  85.     }
  86.     if (lastOpenBraceFound+1<firstEndBraceFound){
  87.     String returnString= orgName.substring(lastOpenBraceFound+1, firstEndBraceFound);
  88.         return returnString;}
  89.     else
  90.     return "";
  91.    
  92.     }
  93.     private static  boolean checkChar(char char2Check)
  94.     {
  95.     if ( char2Check>=65&&char2Check<=90||char2Check>=97&&char2Check<=122)
  96.         {return true;}
  97.     else
  98.         {return false;}
  99.        
  100.        
  101.     }
  102.     private static boolean checkVokal(char char2Check)
  103.     {
  104.         if (char2Check=='a'||char2Check=='o'||char2Check=='u'||char2Check=='i'||char2Check=='e')
  105.         {return true;}
  106.         else
  107.             return false;
  108.     }
  109.     private  String removeClanTag(String orgName)
  110.     {orgName=orgName.trim();
  111.     //find lastStartBrace
  112.     int lastOpenBraceFound=0;
  113.     int firstEndBraceFound=0;
  114.     boolean virginBool=true;
  115.     for (int i=0;i<orgName.length();i++)
  116.     {char tempChar=orgName.charAt(i);
  117.     if (tempChar=='('||tempChar=='['||tempChar=='<'||tempChar=='{'||tempChar=='~')
  118.     {lastOpenBraceFound=i;}
  119.     }
  120.     //find firstEndBrace
  121.     for (int i=0;i<orgName.length();i++)
  122.     {
  123.         char tempChar=orgName.charAt(i);
  124.         if (virginBool==true)
  125.         {
  126.             if (tempChar==')'||tempChar==']'||tempChar=='>'||tempChar=='}')
  127.             {firstEndBraceFound=i;
  128.             virginBool=false;}
  129.            
  130.         }  
  131.     }
  132.    
  133.     String returnOfTheString= orgName.substring(0, lastOpenBraceFound+1)+ orgName.substring(firstEndBraceFound,orgName.length());
  134.     for (int i=0;i<returnOfTheString.length();i++)
  135.     {
  136.     if (checkChar(returnOfTheString.charAt(i))==false)
  137.     {
  138.         returnOfTheString=returnOfTheString.substring(0,i)+returnOfTheString.substring(i+1,returnOfTheString.length());
  139.         i=i-1;
  140.     }
  141.        
  142.     }
  143.  
  144.     return returnOfTheString;
  145.    
  146.     }
  147. /**Function: Generates the long Nick from the full Name
  148.  **/   
  149.     private static String generateLongNick(String fullName)
  150.     {fullName=fullName.trim();
  151.      fullName=fullName.toLowerCase();
  152.      String returnNick = "";
  153.      boolean firstVokalFound=false;
  154.      breakPointer:
  155.      for (int i=0;i<fullName.length();i++)
  156.          {
  157.          
  158.            if (checkVokal(fullName.charAt(i))==true)
  159.            {if (firstVokalFound==true&&i+1<fullName.length())
  160.            {returnNick=fullName.substring(0,i+1);break breakPointer; }
  161.            else
  162.            {firstVokalFound=true;}  
  163.            }
  164.          }
  165.         return returnNick;
  166.     }
  167.     /**
  168.     Function to generate a Short Version of the estimated Nick. Needs the fullname, and the long Nick.
  169.      * @throws Exception
  170.      */
  171.     private static String generateShortNick(String fullName,String longNick) throws Exception
  172.     {if (longNick==null)
  173.     longNick=generateLongNick(fullName);
  174.      if (fullName==null)
  175.          throw new Exception("Player Name is emptyString");
  176.         fullName=fullName.toLowerCase();
  177.     for (int i=0;i<fullName.length();i++)
  178.     {
  179.         if (checkVokal(fullName.charAt(i))==true&&(i+1)*2<fullName.length())
  180.         {return fullName.substring(0, (i+1)*2);     }
  181.     }
  182.         return "";
  183.     }
  184.    
  185.    
  186.    
  187.    
  188.    
  189.    
  190.    
  191.    
  192.    
  193.    
  194.    
  195.  
  196. }
Add Comment
Please, Sign In to add comment