Package com.jitcaforwin.extended.api.artist

Examples of com.jitcaforwin.extended.api.artist.GroupArtist


  public static GroupArtist createGroup(String names, Source source){
    if (!isGroup(names)){
      throw new JitcaUnexpectedError("It was tried to build a group based on an artist's name which is not a group!");
    }
   
    GroupArtist group = new GroupArtistImpl(names, source);
   
    StringBuffer artist = new StringBuffer();
    boolean divider = false;
    for (Token token : Scanner.scan(names)){
      if (token instanceof StringToken){
        artist.append(((StringToken) token).getValue());
        artist.append(" ");
        divider = false;
      } else if (token instanceof DividerToken){
        if (!divider){  // The last token was not a divider
          artist.deleteCharAt(artist.length()-1)// Remove last space
          group.addArtist(artist.toString());
          artist = new StringBuffer(); // Clear String Buffer 
        }
        divider = true;
      }
    }
   
    if (artist.length() > 1){
      artist.deleteCharAt(artist.length() - 1)// Remove last space
      group.addArtist(artist.toString());
    }
   
    return group;
  }
View Full Code Here


    assertFalse(ArtistNameParser.isGroup("Michael"));
  }
 
  @Test
  public void parserTestMichaelJacksonPaulMcCartney(){
    GroupArtist michael_paul = ArtistNameParser.createGroup("Michael Jackson, Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_paul);
   
    GroupArtist michael_and_paul = ArtistNameParser.createGroup("Michael Jackson and Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_and_paul);
   
    GroupArtist michael_and_paul2 = ArtistNameParser.createGroup("Michael Jackson, and Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_and_paul2);
   
    GroupArtist michael_and_paul3 = ArtistNameParser.createGroup("Michael Jackson & Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_and_paul3);
   
    GroupArtist michael_feat_paul = ArtistNameParser.createGroup("Michael Jackson feat. Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_feat_paul);
   
    GroupArtist michael_feat_paul2 = ArtistNameParser.createGroup("Michael Jackson featuring Paul McCartney", this.createSourceMock());
    checkMichaelAndPaul(michael_feat_paul2);
  }
View Full Code Here

    checkMichaelAndPaul(michael_feat_paul2);
  }
 
  @Test
  public void parserTestBigGroup(){
    GroupArtist bigGroup1 = ArtistNameParser.createGroup("MemberA, MemberB, MemberC and MemberD", this.createSourceMock());
    this.checkBigGroup(bigGroup1);
   
    GroupArtist bigGroup2 = ArtistNameParser.createGroup("MemberA, MemberB, MemberC, and MemberD", this.createSourceMock());
    this.checkBigGroup(bigGroup2);
   
    GroupArtist bigGroup3 = ArtistNameParser.createGroup("MemberA, MemberB, MemberC & MemberD", this.createSourceMock());
    this.checkBigGroup(bigGroup3);
  }
View Full Code Here

    Source sourceMock = this.createSourceMock();
   
    Artist memberOne = ArtistImpl.create("MemberOne", sourceMock);
    Artist memberTwo = ArtistImpl.create("MemberTwo", sourceMock);
   
    GroupArtist group = new GroupArtistImpl("Group", sourceMock);
   
    assertTrue(group.size() == 0);
   
    group.addArtist(memberOne);
    assertTrue(group.size() == 1);
    assertTrue(group.getMembers().contains(memberOne));
   
    group.addArtist(memberTwo);
    assertTrue(group.size() == 2);
    assertTrue(group.getMembers().contains(memberTwo));
   
    group.removeArtist(memberOne);
    assertTrue(group.size() == 1);
    assertTrue(group.getMembers().contains(memberTwo));
    assertFalse(group.getMembers().contains(memberOne));
  }
View Full Code Here

  public static GroupArtist createGroup(String names, Source source){
    if (!isGroup(names)){
      throw new JitcaUnexpectedError("It was tried to build a group based on an artist's name which is not a group!");
    }
   
    GroupArtist group = new GroupArtistImpl(names, source);
   
    StringBuffer artist = new StringBuffer();
    boolean divider = false;
    for (Token token : Scanner.scan(names)){
      if (token instanceof StringToken){
        artist.append(((StringToken) token).getValue());
        artist.append(" ");
        divider = false;
      } else if (token instanceof DividerToken){
        if (!divider){  // The last token was not a divider
          artist.deleteCharAt(artist.length()-1)// Remove last space
          group.addArtist(artist.toString());
          artist = new StringBuffer(); // Clear String Buffer 
        }
        divider = true;
      }
    }
   
    if (artist.length() > 1){
      artist.deleteCharAt(artist.length() - 1)// Remove last space
      group.addArtist(artist.toString());
    }
   
    return group;
  }
View Full Code Here

TOP

Related Classes of com.jitcaforwin.extended.api.artist.GroupArtist

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.