public List<AuthorName> getAuthorNameList(String lang) throws SQLException {
List<AuthorName> nameList = new ArrayList<AuthorName>();
PreparedStatement stmt = connection.prepareStatement("SELECT AUTHOR_ID, REAL_NAME AS NAME, DISPLAY_NAME, SHOW_REAL_NAME AS SHOW_NAME FROM PUBLISH_BIOGRAPHY WHERE IS_DELETED = 0 UNION "
+ "SELECT N.AUTHOR_ID, N.PENNAME AS NAME, B.DISPLAY_NAME, N.DISPLAY_IN_AUTHOR_LIST AS SHOW_NAME FROM PUBLISH_BIO_PENNAME N, PUBLISH_BIOGRAPHY B "
+ "WHERE N.AUTHOR_ID = B.AUTHOR_ID AND B.IS_DELETED = 0");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
AuthorName authorName = new AuthorName();
authorName.setAuthorID(rs.getString("AUTHOR_ID"));
String name = rs.getString("NAME");
String displayName = rs.getString("DISPLAY_NAME");
boolean isShowName = rs.getBoolean("SHOW_NAME");
int strokeNo = -1;
if (AppConstants.LANG_SIMPLIFIED_CHINESE.equals(lang)) {
name = StringUtil.convertToSimplified(name);
displayName = StringUtil.convertToSimplified(displayName);
}
/**** Getting Stroke number ******/
PreparedStatement stmt2 = connection.prepareStatement("SELECT STROKE_NO FROM UNICODE_CHAR_STROKE_MAP WHERE UNI_CHAR = ?");
stmt2.setString(1, name.substring(0, 1));
ResultSet rs2 = stmt2.executeQuery();
if (rs2.next())
strokeNo = rs2.getInt("STROKE_NO");
rs2.close();
stmt2.close();
/******* End getting stroke number ******/
authorName.setName(name);
authorName.setDisplayName(displayName);
authorName.setShowName(isShowName);
authorName.setNoStroke(strokeNo);
nameList.add(authorName);
}
rs.close();
stmt.close();
final Map<Integer, Integer> chineseStrokeMap = getUnicodeCharMap();
Collections.sort(nameList, new Comparator<AuthorName>() {
@Override
public int compare(AuthorName n1, AuthorName n2) {
// TODO Auto-generated method stub
return StringUtil.compareString(n1.getName(), n2.getName(), chineseStrokeMap);
}
});
return nameList;
}
Since our application will need to display either Traditional Chinese or Simplified Chinese whenever the public user wants to click on a button to change the language. If the user selects "Simplified Chinese", then the author names will be converted into Simplified Chinese using Java library and their corresponding stroke number will be returned.Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>
Our community of experts have been thoroughly vetted for their expertise and industry experience.