Java代码写歌词 用java编写一首诗( 三 )


Matcher matcher = pattern.matcher(strLine);
if(matcher.find())
{
album=matcher.group(1);
continue;
}
}
if(null == lrcMaker || "".equals(lrcMaker.trim()))
{
Pattern pattern = Pattern.compile("\\[by:(.+?)\\]");
Matcher matcher = pattern.matcher(strLine);
if(matcher.find())
{
lrcMaker=matcher.group(1);
continue;
}
}
int timeNum=0;
String str[] = strLine.split("\\]");
for(int i=0; istr.length; ++i)
{
String str2[] = str[i].split("\\[");
str[i] = str2[str2.length-1];
if(isTime(str[i])){
++timeNum;
}
}
for(int i=0; itimeNum;++i)
{
Statement sm = new Statement();
sm.setTime(str[i]);
if(timeNumstr.length)
{
sm.setLyric(str[str.length-1]);
}
statements.add(sm);
}
}
sortLyric();
}
/*
* judge the string is or not date format.
*/
private boolean isTime(String string)
{
String str[] = string.split(":|\\.");
if(3!=str.length)
{
return false;
}
try{
for(int i=0;istr.length;++i)
{
Integer.parseInt(str[i]);
}
}
catch(NumberFormatException e)
{
Log.e(TAG, "isTime exception:"+e.getMessage());
return false;
}
return true;
}
/*
* sort the word by time.
*/
private void sortLyric()
{
for(int i=0;istatements.size()-1;++i)
{
int index=i;
double delta=Double.MAX_VALUE;
boolean moveFlag = false;
for(int j=i+1;jstatements.size();++j)
{
double sub;
if(0=(sub=statements.get(i).getTime()-statements.get(j).getTime()))
{
continue;
}
moveFlag=true;
if(subdelta)
{
delta=sub;
index=j+1;
}
}
if(moveFlag)
{
statements.add(index, statements.get(i));
statements.remove(i);
--i;
}
}
}
/**
* get title
* @return
*/
public String getTitle(){
return title;
}
/**
* get artist
* @return
*/
public String getArtist(){
return artist;
}
/**
* get album
* @return
*/
public String getAlbum(){
return album;
}
/**
* get lrc maker
* @return
*/
public String getLrcMaker(){
return lrcMaker;
}
/**
* get song list
* @return
*/
public ListStatement getLrcList(){
return statements;
}
}
【Java代码写歌词 用java编写一首诗】Java代码写歌词的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于用java编写一首诗、Java代码写歌词的信息别忘了在本站进行查找喔 。

推荐阅读