proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/UserCheckMidware.java | UserCheckMidware | handle | class UserCheckMidware {
/**
* User query service.
*/
@Inject
private UserQueryService userQueryService;
public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
} |
final String userName = context.pathVar("userName");
if (UserExt.NULL_USER_NAME.equals(userName)) {
context.sendError(404);
context.abort();
}
final JSONObject user = userQueryService.getUserByName(userName);
if (null == user) {
context.sendE... | 64 | 244 | 308 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/Activity1A0001CollectValidationMidware.java | Activity1A0001CollectValidationMidware | handle | class Activity1A0001CollectValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Activity query service.
*/
@Inject
private ActivityQueryService activityQueryService;
public void handle(final RequestContext context) {<F... |
if (Symphonys.ACTIVITY_1A0001_CLOSED) {
context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityClosedLabel")));
context.abort();
return;
}
final Calendar calendar = Calendar.getInstance();
final int dayOfWeek = calendar.get(... | 99 | 432 | 531 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/Activity1A0001ValidationMidware.java | Activity1A0001ValidationMidware | handle | class Activity1A0001ValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Activity query service.
*/
@Inject
private ActivityQueryService activityQueryService;
/**
* Liveness query service.
*/
@Inject
... |
final JSONObject currentUser = Sessions.getUser();
final String userId = currentUser.optString(Keys.OBJECT_ID);
final int currentLiveness = livenessQueryService.getCurrentLivenessPoint(userId);
final int livenessMax = Symphonys.ACTIVITY_YESTERDAY_REWARD_MAX;
final float liveness... | 130 | 959 | 1,089 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/ChatMsgAddValidationMidware.java | ChatMsgAddValidationMidware | handle | class ChatMsgAddValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Option query service.
*/
@Inject
private OptionQueryService optionQueryService;
/**
* User query service.
*/
@Inject
private UserQu... |
final Request request = context.getRequest();
final JSONObject requestJSONObject = context.requestJSON();
request.setAttribute(Keys.REQUEST, requestJSONObject);
final JSONObject currentUser = Sessions.getUser();
if (System.currentTimeMillis() - currentUser.optLong(UserExt.USER_L... | 123 | 366 | 489 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/CommentAddValidationMidware.java | CommentAddValidationMidware | handle | class CommentAddValidationMidware {
public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
} |
final Request request = context.getRequest();
final JSONObject requestJSONObject = context.requestJSON();
request.setAttribute(Keys.REQUEST, requestJSONObject);
final BeanManager beanManager = BeanManager.getInstance();
final LangPropsService langPropsService = beanManager.getRe... | 36 | 696 | 732 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/CommentUpdateValidationMidware.java | CommentUpdateValidationMidware | handle | class CommentUpdateValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Comment query service.
*/
@Inject
private CommentQueryService commentQueryService;
/**
* Article query service.
*/
@Inject
priva... |
final Request request = context.getRequest();
final JSONObject requestJSONObject = context.requestJSON();
request.setAttribute(Keys.REQUEST, requestJSONObject);
final BeanManager beanManager = BeanManager.getInstance();
final LangPropsService langPropsService = beanManager.getRe... | 151 | 305 | 456 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/PointTransferValidationMidware.java | PointTransferValidationMidware | handle | class PointTransferValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* User query service.
*/
@Inject
private UserQueryService userQueryService;
public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
... |
final Request request = context.getRequest();
final JSONObject requestJSONObject = context.requestJSON();
final String userName = requestJSONObject.optString(User.USER_NAME);
if (StringUtils.isBlank(userName) || UserExt.COM_BOT_NAME.equals(userName)) {
context.renderJSON(ne... | 94 | 770 | 864 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/UpdatePasswordValidationMidware.java | UpdatePasswordValidationMidware | handle | class UpdatePasswordValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
} |
final JSONObject requestJSONObject = context.requestJSON();
final String oldPwd = requestJSONObject.optString(User.USER_PASSWORD);
if (StringUtils.isBlank(oldPwd)) {
context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("emptyOldPwdLabel")));
context.abo... | 64 | 192 | 256 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/UpdateProfilesValidationMidware.java | UpdateProfilesValidationMidware | handle | class UpdateProfilesValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Max user nickname length.
*/
public static final int MAX_USER_NICKNAME_LENGTH = 20;
/**
* Max user URL length.
*/
public static final i... |
final JSONObject requestJSONObject = context.requestJSON();
final String userURL = requestJSONObject.optString(User.USER_URL);
if (StringUtils.isNotBlank(userURL) && invalidUserURL(userURL)) {
context.renderJSON(new JSONObject().put(Keys.MSG, "URL" + langPropsService.get("colonLabel... | 317 | 1,277 | 1,594 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/UserForgetPwdValidationMidware.java | UserForgetPwdValidationMidware | handle | class UserForgetPwdValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
} |
final JSONObject requestJSONObject = context.requestJSON();
final String email = requestJSONObject.optString(User.USER_EMAIL);
final String captcha = requestJSONObject.optString(CaptchaProcessor.CAPTCHA);
if (CaptchaProcessor.invalidCaptcha(captcha)) {
context.renderJSON(ne... | 67 | 219 | 286 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/processor/middleware/validate/UserRegister2ValidationMidware.java | UserRegister2ValidationMidware | handle | class UserRegister2ValidationMidware {
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Option query service.
*/
@Inject
private OptionQueryService optionQueryService;
/**
* Max password length.
*
* <p>
* MD5 32
... |
final JSONObject requestJSONObject = context.requestJSON();
// check if admin allow to register
final JSONObject option = optionQueryService.getOption(Option.ID_C_MISC_ALLOW_REGISTER);
if ("1".equals(option.optString(Option.OPTION_VALUE))) {
context.renderJSON(new JSONObjec... | 280 | 349 | 629 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/ArticleRepository.java | ArticleRepository | getRandomly | class ArticleRepository extends AbstractRepository {
/**
* Article cache.
*/
@Inject
private ArticleCache articleCache;
/**
* Public constructor.
*/
public ArticleRepository() {
super(Article.ARTICLE);
}
@Override
public void remove(final String id) throws ... |
final List<JSONObject> ret = new ArrayList<>();
final double mid = Math.random();
Query query = new Query().
setFilter(CompositeFilterOperator.and(new PropertyFilter(Article.ARTICLE_RANDOM_DOUBLE, FilterOperator.GREATER_THAN_OR_EQUAL, mid),
new PropertyF... | 462 | 673 | 1,135 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/CommentRepository.java | CommentRepository | removeComment | class CommentRepository extends AbstractRepository {
/**
* Comment cache.
*/
@Inject
private CommentCache commentCache;
/**
* Article repository.
*/
@Inject
private ArticleRepository articleRepository;
/**
* User repository.
*/
@Inject
private UserRep... |
final JSONObject comment = get(commentId);
if (null == comment) {
return;
}
remove(comment.optString(Keys.OBJECT_ID));
final String commentAuthorId = comment.optString(Comment.COMMENT_AUTHOR_ID);
final JSONObject commenter = userRepository.get(commentAuthor... | 513 | 924 | 1,437 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/DomainTagRepository.java | DomainTagRepository | getByTagId | class DomainTagRepository extends AbstractRepository {
/**
* Public constructor.
*/
public DomainTagRepository() {
super(Domain.DOMAIN + "_" + Tag.TAG);
}
/**
* Gets domain-tag relations by the specified domain id.
*
* @param domainId the specified domain id
... |
final Query query = new Query().
setFilter(new PropertyFilter(Tag.TAG + "_" + Keys.OBJECT_ID, FilterOperator.EQUAL, tagId)).
setPage(currentPageNum, pageSize).setPageCount(1);
return get(query);
| 727 | 72 | 799 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/EmotionRepository.java | EmotionRepository | getUserEmojis | class EmotionRepository extends AbstractRepository {
/**
* Public constructor.
*/
public EmotionRepository() {
super(Emotion.EMOTION);
}
/**
* Gets a user's emotion (emoji with type=0).
*
* @param userId the specified user id
* @return emoji string join with {@cod... |
final Query query = new Query().setFilter(CompositeFilterOperator.and(
new PropertyFilter(Emotion.EMOTION_USER_ID, FilterOperator.EQUAL, userId),
new PropertyFilter(Emotion.EMOTION_TYPE, FilterOperator.EQUAL, Emotion.EMOTION_TYPE_C_EMOJI))).
addSort(Emotion.EMOTI... | 251 | 240 | 491 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/FollowRepository.java | FollowRepository | removeByFollowerIdAndFollowingId | class FollowRepository extends AbstractRepository {
/**
* Public constructor.
*/
public FollowRepository() {
super(Follow.FOLLOW);
}
/**
* Removes a follow relationship by the specified follower id and the specified following entity id.
*
* @param followerId the spe... |
final JSONObject toRemove = getByFollowerIdAndFollowingId(followerId, followingId, followingType);
if (null == toRemove) {
return;
}
remove(toRemove.optString(Keys.OBJECT_ID));
| 908 | 64 | 972 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/LinkRepository.java | LinkRepository | getLink | class LinkRepository extends AbstractRepository {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LinkRepository.class);
/**
* Gets a link with the specified address.
*
* @param addr the specified address
* @return a link, returns {@code null} if no... |
final String hash = DigestUtils.sha1Hex(addr);
final Query query = new Query().setFilter(new PropertyFilter(Link.LINK_ADDR_HASH, FilterOperator.EQUAL, hash)).
setPageCount(1).setPage(1, 1);
try {
return getFirst(query);
} catch (final Exception e) {
... | 147 | 139 | 286 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/LivenessRepository.java | LivenessRepository | getByUserAndDate | class LivenessRepository extends AbstractRepository {
/**
* Public constructor.
*/
public LivenessRepository() {
super(Liveness.LIVENESS);
}
/**
* Remove liveness by the specified user id.
*
* @param userId the specified user id
* @throws RepositoryException repos... |
final Query query = new Query().setFilter(CompositeFilterOperator.and(
new PropertyFilter(Liveness.LIVENESS_USER_ID, FilterOperator.EQUAL, userId),
new PropertyFilter(Liveness.LIVENESS_DATE, FilterOperator.EQUAL, date))).setPageCount(1);
return getFirst(query);
| 259 | 92 | 351 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/NotificationRepository.java | NotificationRepository | hasSentByDataIdAndType | class NotificationRepository extends AbstractRepository {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(NotificationRepository.class);
/**
* Public constructor.
*/
public NotificationRepository() {
super(Notification.NOTIFICATION);
}
/*... |
try {
return 0 < count(new Query().setFilter(CompositeFilterOperator.and(
new PropertyFilter(Notification.NOTIFICATION_USER_ID, FilterOperator.EQUAL, userId),
new PropertyFilter(Notification.NOTIFICATION_DATA_ID, FilterOperator.EQUAL, dataId),
... | 412 | 177 | 589 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/OptionRepository.java | OptionRepository | get | class OptionRepository extends AbstractRepository {
/**
* Option cache.
*/
@Inject
private OptionCache optionCache;
/**
* Public constructor.
*/
public OptionRepository() {
super(Option.OPTION);
}
@Override
public void remove(final String id) throws Reposit... |
JSONObject ret = optionCache.getOption(id);
if (null != ret) {
return ret;
}
ret = super.get(id);
if (null == ret) {
return null;
}
optionCache.putOption(ret);
return ret;
| 216 | 80 | 296 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/PointtransferRepository.java | PointtransferRepository | getActivityEatingSnakeAvg | class PointtransferRepository extends AbstractRepository {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(PointtransferRepository.class);
/**
* Gets average point of activity eating snake of a user specified by the given user id.
*
* @param userId the g... |
int ret = Pointtransfer.TRANSFER_SUM_C_ACTIVITY_EATINGSNAKE;
try {
final List<JSONObject> result = select("SELECT\n"
+ " AVG(sum) AS point\n"
+ "FROM\n"
+ " `" + getName() + "`\n"
+ "WHERE\n"
... | 197 | 243 | 440 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/ReferralRepository.java | ReferralRepository | getByDataIdAndIP | class ReferralRepository extends AbstractRepository {
/**
* Gets a referral by the specified data id and IP.
*
* @param dataId the specified data id
* @param ip the specified IP
* @return referral, returns {@code null} if not found
* @throws RepositoryException repository exceptio... |
final Query query = new Query().setFilter(CompositeFilterOperator.and(
new PropertyFilter(Referral.REFERRAL_DATA_ID, FilterOperator.EQUAL, dataId),
new PropertyFilter(Referral.REFERRAL_IP, FilterOperator.EQUAL, ip))).setPageCount(1).setPage(1, 1);
return getFirst(query);... | 161 | 98 | 259 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/TagArticleRepository.java | TagArticleRepository | getByTagId | class TagArticleRepository extends AbstractRepository {
/**
* Public constructor.
*/
public TagArticleRepository() {
super(Tag.TAG + "_" + Article.ARTICLE);
}
/**
* Removes tag-articles relations by the specified article id.
*
* @param articleId the specified article i... |
final Query query = new Query().
setFilter(new PropertyFilter(Tag.TAG + "_" + Keys.OBJECT_ID, FilterOperator.EQUAL, tagId)).
addSort(Article.ARTICLE + "_" + Keys.OBJECT_ID, SortDirection.DESCENDING).
setPage(currentPageNum, pageSize).setPageCount(1);
ret... | 625 | 103 | 728 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/TagTagRepository.java | TagTagRepository | getByTag2Id | class TagTagRepository extends AbstractRepository {
/**
* Public constructor.
*/
public TagTagRepository() {
super(Tag.TAG + "_" + Tag.TAG);
}
/**
* Gets tag-tag relations by the specified tag1 id.
*
* @param tag1Id the specified tag1 id
* @param currentPa... |
final List<Filter> filters = new ArrayList<>();
filters.add(new PropertyFilter(Tag.TAG + "2_" + Keys.OBJECT_ID, FilterOperator.EQUAL, tag2Id));
filters.add(new PropertyFilter(Common.WEIGHT, FilterOperator.GREATER_THAN_OR_EQUAL, Symphonys.TAG_RELATED_WEIGHT));
final Query query = new Qu... | 1,040 | 170 | 1,210 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/UserRepository.java | UserRepository | get | class UserRepository extends AbstractRepository {
/**
* User cache.
*/
@Inject
private UserCache userCache;
/**
* Public constructor.
*/
public UserRepository() {
super(User.USER);
}
@Override
public JSONObject get(final String id) throws RepositoryExceptio... |
JSONObject ret = userCache.getUser(id);
if (null != ret) {
return ret;
}
ret = super.get(id);
if (null == ret) {
return null;
}
userCache.putUser(ret);
return ret;
| 795 | 81 | 876 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/UserTagRepository.java | UserTagRepository | getByUserId | class UserTagRepository extends AbstractRepository {
/**
* Public constructor.
*/
public UserTagRepository() {
super(User.USER + "_" + Tag.TAG);
}
/**
* Removes user-tag relations by the specified user id and tag id.
*
* @param userId the specified user id
* @para... |
final Query query = new Query().setFilter(new PropertyFilter(User.USER + "_" + Keys.OBJECT_ID, FilterOperator.EQUAL, userId)).
setPage(currentPageNum, pageSize).setPageCount(1);
return get(query);
| 897 | 70 | 967 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/repository/VoteRepository.java | VoteRepository | removeIfExists | class VoteRepository extends AbstractRepository {
/**
* Removes votes by the specified data id.
*
* @param dataId the specified data id
* @throws RepositoryException repository exception
*/
public void removeByDataId(final String dataId) throws RepositoryException {
remove(new ... |
final List<Filter> filters = new ArrayList<>();
filters.add(new PropertyFilter(Vote.USER_ID, FilterOperator.EQUAL, userId));
filters.add(new PropertyFilter(Vote.DATA_ID, FilterOperator.EQUAL, dataId));
filters.add(new PropertyFilter(Vote.DATA_TYPE, FilterOperator.EQUAL, dataType));
... | 275 | 191 | 466 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/AvatarQueryService.java | AvatarQueryService | getAvatarURLByUser | class AvatarQueryService {
/**
* Default avatar URL.
*/
public static final String DEFAULT_AVATAR_URL = Latkes.getStaticServePath() + "/images/user-thumbnail.png";
/**
* Fills the specified user thumbnail URL.
*
* @param user the specified user
*/
public void fillUserAvat... |
if (null == user) {
return getDefaultAvatarURL(size);
}
final int viewMode = Sessions.getAvatarViewMode();
String originalURL = user.optString(UserExt.USER_AVATAR_URL);
if (StringUtils.isBlank(originalURL)) {
originalURL = DEFAULT_AVATAR_URL;
}
... | 1,139 | 553 | 1,692 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/BreezemoonMgmtService.java | BreezemoonMgmtService | updateBreezemoon | class BreezemoonMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(BreezemoonMgmtService.class);
/**
* Breezemoon repository.
*/
@Inject
private BreezemoonRepository breezemoonRepository;
/**
* User repository.
*/
@Inject... |
final String content = requestJSONObject.optString(Breezemoon.BREEZEMOON_CONTENT);
if (optionQueryService.containReservedWord(content)) {
throw new ServiceException(langPropsService.get("contentContainReservedWordLabel"));
}
final String id = requestJSONObject.optString(Key... | 1,174 | 628 | 1,802 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/CacheMgmtService.java | CacheMgmtService | statusReport | class CacheMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(CacheMgmtService.class);
/**
* Global locks
*/
private static final Cache LOCKS = CacheFactory.getCache("locks");
/**
* Tag cache.
*/
@Inject
private TagCache ... |
final JSONObject ret = new JSONObject();
ret.put(Common.ONLINE_VISITOR_CNT, optionQueryService.getOnlineVisitorCount());
ret.put(Common.ONLINE_MEMBER_CNT, optionQueryService.getOnlineMemberCount());
ret.put(Common.ONLINE_CHAT_CNT, ChatroomChannel.SESSIONS.size());
ret.put(Common... | 729 | 458 | 1,187 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/CharacterQueryService.java | CharacterQueryService | getWrittenCharacterCount | class CharacterQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(CharacterQueryService.class);
/**
* Character repository.
*/
@Inject
private CharacterRepository characterRepository;
/**
* Language service.
*/
@Inject
... |
try {
final List<JSONObject> result = characterRepository.select("select count(DISTINCT characterContent) from "
+ characterRepository.getName());
if (null == result || result.isEmpty()) {
return 0;
}
return result.get(0).opt... | 1,887 | 127 | 2,014 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/CronMgmtService.java | CronMgmtService | start | class CronMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(CronMgmtService.class);
/**
* Article management service.
*/
@Inject
private ArticleMgmtService articleMgmtService;
/**
* Verifycode management service.
*/
@Inj... |
long delay = 10000;
Symphonys.SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate(() -> {
try {
articleMgmtService.expireStick();
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Executes cron failed", e);
} finally {
... | 468 | 691 | 1,159 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/DomainMgmtService.java | DomainMgmtService | addDomainTag | class DomainMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(DomainMgmtService.class);
/**
* Domain repository.
*/
@Inject
private DomainRepository domainRepository;
/**
* Domain tag repository.
*/
@Inject
private D... |
try {
final String domainId = domainTag.optString(Domain.DOMAIN + "_" + Keys.OBJECT_ID);
final JSONObject domain = domainRepository.get(domainId);
domain.put(Domain.DOMAIN_TAG_COUNT, domain.optInt(Domain.DOMAIN_TAG_COUNT) + 1);
domainRepository.update(domainId, ... | 1,587 | 161 | 1,748 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/EmotionMgmtService.java | EmotionMgmtService | setEmotionList | class EmotionMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(EmotionMgmtService.class);
/**
* Emotion repository.
*/
@Inject
private EmotionRepository emotionRepository;
/**
* Sets a user's emotions.
*
* @param userId... |
final Transaction transaction = emotionRepository.beginTransaction();
try {
// clears the user all emotions
emotionRepository.removeByUserId(userId);
final Set<String> emotionSet = new HashSet<>(); // for deduplication
final String[] emotionArray = emot... | 163 | 378 | 541 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/EmotionQueryService.java | EmotionQueryService | getEmojis | class EmotionQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(EmotionQueryService.class);
/**
* Common used emoji string.
*/
private static final String COMMON_USED = "smile,flushed,joy,sob,yum,trollface,tada,heart,+1,ok_hand,pray";
/**... |
try {
final String ret = emotionRepository.getUserEmojis(userId);
if (StringUtils.isBlank(ret)) {
return COMMON_USED;
}
return ret;
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, e.getMessage());
... | 230 | 98 | 328 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/InvitecodeMgmtService.java | InvitecodeMgmtService | adminGenInvitecodes | class InvitecodeMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(InvitecodeMgmtService.class);
/**
* Invitecode repository.
*/
@Inject
private InvitecodeRepository invitecodeRepository;
/**
* Expires invitecodes.
*/
@Tr... |
final Transaction transaction = invitecodeRepository.beginTransaction();
try {
for (int i = 0; i < quantity; i++) {
final JSONObject invitecode = new JSONObject();
invitecode.put(Invitecode.CODE, RandomStringUtils.randomAlphanumeric(16));
inv... | 1,093 | 262 | 1,355 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/InvitecodeQueryService.java | InvitecodeQueryService | getInvitecodes | class InvitecodeQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(InvitecodeQueryService.class);
/**
* Invitecode repository.
*/
@Inject
private InvitecodeRepository invitecodeRepository;
/**
* Gets valid invitecodes by the spec... |
final JSONObject ret = new JSONObject();
final int currentPageNum = requestJSONObject.optInt(Pagination.PAGINATION_CURRENT_PAGE_NUM);
final int pageSize = requestJSONObject.optInt(Pagination.PAGINATION_PAGE_SIZE);
final int windowSize = requestJSONObject.optInt(Pagination.PAGINATION_WI... | 1,162 | 410 | 1,572 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/LinkMgmtService.java | LinkMgmtService | addLink | class LinkMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LinkMgmtService.class);
/**
* Link repository.
*/
@Inject
private LinkRepository linkRepository;
/**
* Adds a link with the specified URL.
*
* @param url the s... |
final String linkAddr = link.optString(Link.LINK_ADDR);
final JSONObject old = linkRepository.getLink(linkAddr);
if (null != old) {
old.put(Link.LINK_CLICK_CNT, link.optInt(Link.LINK_CLICK_CNT));
singlePing(old);
return;
}
final Transaction ... | 1,775 | 202 | 1,977 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/LinkQueryService.java | LinkQueryService | getTopLink | class LinkQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LinkQueryService.class);
/**
* Link repository.
*/
@Inject
private LinkRepository linkRepository;
/**
* Tag cache.
*/
@Inject
private TagCache tagCache;
... |
final List<JSONObject> ret = new ArrayList<>();
try {
final List<JSONObject> links = linkRepository.select("SELECT\n" +
"\t*\n" +
"FROM\n" +
"\t`symphony_link`\n" +
"WHERE\n" +
"\tlinkPingEr... | 168 | 239 | 407 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/LivenessMgmtService.java | LivenessMgmtService | incLiveness | class LivenessMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LivenessMgmtService.class);
/**
* Liveness repository.
*/
@Inject
private LivenessRepository livenessRepository;
/**
* Increments a field of the specified liveness.
... |
Stopwatchs.start("Inc liveness");
final String date = DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd");
try {
JSONObject liveness = livenessRepository.getByUserAndDate(userId, date);
if (null == liveness) {
liveness = new JSONObject();
... | 157 | 484 | 641 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/LivenessQueryService.java | LivenessQueryService | getCurrentLivenessPoint | class LivenessQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LivenessQueryService.class);
/**
* Liveness repository.
*/
@Inject
private LivenessRepository livenessRepository;
/**
* Gets point of current liveness.
*
... |
Stopwatchs.start("Gets liveness");
try {
final String date = DateFormatUtils.format(new Date(), "yyyyMMdd");
try {
final JSONObject liveness = livenessRepository.getByUserAndDate(userId, date);
if (null == liveness) {
return 0... | 317 | 162 | 479 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/MailMgmtService.java | MailMgmtService | sendWeeklyNewsletter | class MailMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(MailMgmtService.class);
/**
* User repository.
*/
@Inject
private UserRepository userRepository;
/**
* Article repository.
*/
@Inject
private ArticleReposit... |
final Calendar calendar = Calendar.getInstance();
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
final int minute = calendar.get(Calendar.MINUTE);
if (13 != hour || 55 > minute) {
return;
}
if (weeklyNewsletterSending) {
return;
}
... | 306 | 1,486 | 1,792 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/OperationMgmtService.java | OperationMgmtService | addOperation | class OperationMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(OperationMgmtService.class);
/**
* Operation repository.
*/
@Inject
private OperationRepository operationRepository;
/**
* Adds the specified operation.
*
... |
try {
operationRepository.add(operation);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Adds an operation failed", e);
}
| 131 | 49 | 180 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/OperationQueryService.java | OperationQueryService | getAuditlogs | class OperationQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(OperationQueryService.class);
/**
* Operation repository.
*/
@Inject
private OperationRepository operationRepository;
/**
* User repository.
*/
@Inject
... |
final JSONObject ret = new JSONObject();
final int currentPageNum = requestJSONObject.optInt(Pagination.PAGINATION_CURRENT_PAGE_NUM);
final int pageSize = requestJSONObject.optInt(Pagination.PAGINATION_PAGE_SIZE);
final int windowSize = requestJSONObject.optInt(Pagination.PAGINATION_WI... | 417 | 762 | 1,179 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/OptionMgmtService.java | OptionMgmtService | updateOption | class OptionMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(OptionMgmtService.class);
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/**
* Removes an option.
*
* @param id the specified... |
final Transaction transaction = optionRepository.beginTransaction();
try {
optionRepository.update(optionId, option);
transaction.commit();
} catch (final RepositoryException e) {
if (transaction.isActive()) {
transaction.rollback();
... | 415 | 106 | 521 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/OptionQueryService.java | OptionQueryService | getMisc | class OptionQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(OptionQueryService.class);
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/**
* Language service.
*/
@Inject
private Lang... |
final Query query = new Query().setFilter(new PropertyFilter(Option.OPTION_CATEGORY, FilterOperator.EQUAL, Option.CATEGORY_C_MISC));
try {
final List<JSONObject> ret = optionRepository.getList(query);
for (final JSONObject option : ret) {
option.put("label", lang... | 1,657 | 161 | 1,818 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/PointtransferMgmtService.java | PointtransferMgmtService | transfer | class PointtransferMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(PointtransferMgmtService.class);
/**
* Pointtransfer repository.
*/
@Inject
private PointtransferRepository pointtransferRepository;
/**
* User repository.
... |
if (StringUtils.equals(fromId, toId)) {
LOGGER.log(Level.WARN, "The from id is equal to the to id [" + fromId + "]");
return null;
}
final Transaction transaction = pointtransferRepository.beginTransaction();
try {
int fromBalance = 0;
i... | 308 | 702 | 1,010 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/PostExportService.java | PostExportService | exportPosts | class PostExportService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(PostExportService.class);
/**
* User repository.
*/
@Inject
private UserRepository userRepository;
/**
* Article repository.
*/
@Inject
private ArticleRep... |
final int pointDataExport = Symphonys.POINT_DATA_EXPORT;
try {
final JSONObject user = userRepository.get(userId);
final int balance = user.optInt(UserExt.USER_POINT);
if (balance - pointDataExport < 0) {
return "-1";
}
} catch (f... | 253 | 1,362 | 1,615 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/ReferralMgmtService.java | ReferralMgmtService | updateReferral | class ReferralMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(ReferralMgmtService.class);
/**
* Referral repository.
*/
@Inject
private ReferralRepository referralRepository;
/**
* Adds or updates a referral.
*
* @par... |
final String dataId = referral.optString(Referral.REFERRAL_DATA_ID);
final String ip = referral.optString(Referral.REFERRAL_IP);
try {
JSONObject record = referralRepository.getByDataIdAndIP(dataId, ip);
if (null == record) {
record = new JSONObject();
... | 152 | 468 | 620 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/ReportMgmtService.java | ReportMgmtService | makeReportHandled | class ReportMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(ReportMgmtService.class);
/**
* Report repository.
*/
@Inject
private ReportRepository reportRepository;
/**
* Language service.
*/
@Inject
private LangPr... |
final Transaction transaction = reportRepository.beginTransaction();
try {
final JSONObject report = reportRepository.get(reportId);
report.put(Report.REPORT_HANDLED, Report.REPORT_HANDLED_C_YES);
reportRepository.update(reportId, report);
transaction.co... | 613 | 322 | 935 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/RewardMgmtService.java | RewardMgmtService | addReward | class RewardMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(RewardMgmtService.class);
/**
* Reward repository.
*/
@Inject
private RewardRepository rewardRepository;
/**
* Adds a reward with the specified request json object.
... |
try {
return rewardRepository.add(requestJSONObject);
} catch (final RepositoryException e) {
final String msg = "Adds reward failed";
LOGGER.log(Level.ERROR, msg, e);
throw new ServiceException(msg);
}
| 207 | 71 | 278 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/RewardQueryService.java | RewardQueryService | rewardedCount | class RewardQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(RewardQueryService.class);
/**
* Reward repository.
*/
@Inject
private RewardRepository rewardRepository;
/**
* Gets rewarded count.
*
* @param dataId the s... |
final Query query = new Query();
final List<Filter> filters = new ArrayList<>();
filters.add(new PropertyFilter(Reward.DATA_ID, FilterOperator.EQUAL, dataId));
filters.add(new PropertyFilter(Reward.TYPE, FilterOperator.EQUAL, type));
query.setFilter(new CompositeFilter(Composit... | 445 | 155 | 600 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/RoleMgmtService.java | RoleMgmtService | addRole | class RoleMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(RoleMgmtService.class);
/**
* Role repository.
*/
@Inject
private RoleRepository roleRepository;
/**
* Role-Permission repository.
*/
@Inject
private RolePe... |
try {
final String roleName = role.optString(Role.ROLE_NAME);
final Query query = new Query().
setFilter(new PropertyFilter(Role.ROLE_NAME, FilterOperator.EQUAL, roleName));
if (roleRepository.count(query) > 0) {
return;
}
... | 569 | 128 | 697 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/SearchQueryService.java | SearchQueryService | searchElasticsearch | class SearchQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(SearchQueryService.class);
/**
* Searches by Elasticsearch.
*
* @param type the specified document type
* @param keyword the specified keyword
* @param curren... |
try {
final JSONObject reqData = new JSONObject();
final JSONObject q = new JSONObject();
final JSONObject and = new JSONObject();
q.put("and", and);
final JSONArray query = new JSONArray();
and.put("query", query);
final JSONO... | 771 | 693 | 1,464 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/ShortLinkQueryService.java | ShortLinkQueryService | linkArticle | class ShortLinkQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(ShortLinkQueryService.class);
/**
* Article pattern - full.
*/
private static final Pattern ARTICLE_PATTERN_FULL = Pattern.compile(Latkes.getServePath() + "/article/\\d{13,15}[?... |
Stopwatchs.start("Link article");
StringBuffer contentBuilder = new StringBuffer();
try {
Matcher matcher = ARTICLE_PATTERN_FULL.matcher(content);
final String[] codeBlocks = StringUtils.substringsBetween(content, "```", "```");
String codes = "";
... | 210 | 702 | 912 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/SitemapQueryService.java | SitemapQueryService | genDomains | class SitemapQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(SitemapQueryService.class);
/**
* Article repository.
*/
@Inject
private ArticleRepository articleRepository;
/**
* Domain cache.
*/
@Inject
private Dom... |
final List<JSONObject> domains = domainCache.getDomains(Integer.MAX_VALUE);
for (final JSONObject domain : domains) {
final String permalink = Latkes.getServePath() + "/domain/" + domain.optString(Domain.DOMAIN_URI);
final Sitemap.URL url = new Sitemap.URL();
url.s... | 659 | 138 | 797 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/VerifycodeMgmtService.java | VerifycodeMgmtService | sendEmailVerifycode | class VerifycodeMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(VerifycodeMgmtService.class);
/**
* Verifycode repository.
*/
@Inject
private VerifycodeRepository verifycodeRepository;
/**
* User repository.
*/
@Inject... |
final List<Filter> filters = new ArrayList<>();
filters.add(new PropertyFilter(Verifycode.TYPE, FilterOperator.EQUAL, Verifycode.TYPE_C_EMAIL));
filters.add(new PropertyFilter(Verifycode.STATUS, FilterOperator.EQUAL, Verifycode.STATUS_C_UNSENT));
final Query query = new Query().setFilte... | 672 | 745 | 1,417 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/VerifycodeQueryService.java | VerifycodeQueryService | getVerifycodeByUserId | class VerifycodeQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(VerifycodeQueryService.class);
/**
* Verifycode repository.
*/
@Inject
private VerifycodeRepository verifycodeRepository;
/**
* Gets a verifycode with the specifi... |
final Query query = new Query().setFilter(CompositeFilterOperator.and(
new PropertyFilter(Verifycode.TYPE, FilterOperator.EQUAL, type),
new PropertyFilter(Verifycode.BIZ_TYPE, FilterOperator.EQUAL, bizType),
new PropertyFilter(Verifycode.USER_ID, FilterOperator.E... | 345 | 165 | 510 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/VisitMgmtService.java | VisitMgmtService | expire | class VisitMgmtService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(VisitMgmtService.class);
/**
* Visit repository.
*/
@Inject
private VisitRepository visitRepository;
/**
* Adds the specified visit.
*
* @param visit the spec... |
try {
final Query query = new Query().setFilter(new PropertyFilter(Visit.VISIT_EXPIRED, FilterOperator.LESS_THAN_OR_EQUAL, System.currentTimeMillis()))
.setPageCount(1);
visitRepository.remove(query);
} catch (final Exception e) {
LOGGER.log(Level... | 564 | 105 | 669 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/service/VoteQueryService.java | VoteQueryService | isOwn | class VoteQueryService {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(VoteQueryService.class);
/**
* Vote repository.
*/
@Inject
private VoteRepository voteRepository;
/**
* Article repository.
*/
@Inject
private ArticleRepos... |
try {
if (Vote.DATA_TYPE_C_ARTICLE == dataType) {
final JSONObject article = articleRepository.get(dataId);
if (null == article) {
LOGGER.log(Level.ERROR, "Not found article [id={}]", dataId);
return false;
}
... | 511 | 261 | 772 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Escapes.java | Escapes | escapeHTML | class Escapes {
/**
* Sanitizes the specified file name.
*
* @param unsanitized the specified file name
* @return sanitized file name
*/
public static String sanitizeFilename(final String unsanitized) {
return unsanitized.
replaceAll("[\\?\\\\/:|<>\\*\\[\\]]", "-... |
final Iterator<String> keys = jsonObject.keys();
while (keys.hasNext()) {
final String key = keys.next();
if (jsonObject.opt(key) instanceof String) {
jsonObject.put(key, Encode.forHtml(jsonObject.optString(key)));
}
}
| 273 | 82 | 355 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Geos.java | Geos | getAddress | class Geos {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(Geos.class);
/**
* Private constructor.
*/
private Geos() {
}
/**
* Gets country, province and city of the specified IP.
*
* @param ip the specified IP
* @return add... |
final String ak = Symphonys.BAIDU_LBS_AK;
if (StringUtils.isBlank(ak) || !Strings.isIPv4(ip)) {
return null;
}
HttpURLConnection conn = null;
try {
final URL url = new URL("http://api.map.baidu.com/location/ip?ip=" + ip + "&ak=" + ak);
conn =... | 663 | 579 | 1,242 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Gravatars.java | Gravatars | getRandomAvatarData | class Gravatars {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(Gravatars.class);
/**
* Styles.
*/
private static final String[] d = new String[]{"identicon", "monsterid", "wavatar", "retro", "robohash"};
/**
* Gets random avatar image byte ar... |
try {
String h = hash;
if (StringUtils.isBlank(h)) {
h = RandomStringUtils.randomAlphanumeric(16);
}
final HttpResponse response = HttpRequest.get("http://www.gravatar.com/avatar/" + h + "?s=256&d=" + d[RandomUtils.nextInt(0, d.length)]).
... | 206 | 228 | 434 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Headers.java | Headers | getSuffix | class Headers {
/**
* Gets suffix (for example jpg) of the specified file.
*
* @param file the specified file
* @return suffix
*/
public static String getSuffix(final FileUpload file) {<FILL_FUNCTION_BODY>}
/**
* Gets suffix (for example jpg) with the specified content type.
... |
final String fileName = file.getFilename();
String ret = StringUtils.substringAfterLast(fileName, ".");
if (StringUtils.isNotBlank(ret)) {
return ret;
}
final String contentType = file.getContentType();
return getSuffix(contentType);
| 418 | 82 | 500 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Images.java | Images | qiniuImgProcessing | class Images {
/**
* Qiniu image processing.
*
* @param content the specified article content
* @return processed content
*/
public static String qiniuImgProcessing(final String content) {<FILL_FUNCTION_BODY>}
/**
* Private constructor.
*/
private Images() {
}
} |
String ret = content;
if (!Symphonys.QN_ENABLED) {
return ret;
}
final String qiniuDomain = Symphonys.UPLOAD_QINIU_DOMAIN;
final String html = Markdowns.toHTML(content);
final String[] imgSrcs = StringUtils.substringsBetween(html, "<img src=\"", "\"");
... | 94 | 258 | 352 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Links.java | Links | getLink | class Links {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(Links.class);
/**
* Gets link from the specified URL.
*
* @param url the specified URL
* @return link like this: <pre>
* {
* "linkAddr": "https://ld246.com/article/144057317... |
try {
return Symphonys.EXECUTOR_SERVICE.submit(new Spider(url)).get();
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Parses URL [" + url + "] failed", e);
return null;
}
| 1,328 | 78 | 1,406 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/MediaPlayers.java | MediaPlayers | renderAudio | class MediaPlayers {
/**
* Video suffix.
*/
private static final String VIDEO_SUFFIX = "rm|rmvb|3gp|avi|mpeg|mp4|wmv|mkv|dat|asf|flv|mov|webm";
/**
* Video URL regex.
*/
private static final String VIDEO_URL_REGEX = "<p>( )*<a href.*\\.(" + VIDEO_SUFFIX + ").*</a>( )*</p>";
/*... |
final StringBuffer contentBuilder = new StringBuffer();
final Matcher m = AUDIO_PATTERN.matcher(content);
while (m.find()) {
final String g = m.group();
String audioName = StringUtils.substringBetween(g, "\">", "</a>");
audioName = StringUtils.substringBefor... | 1,195 | 246 | 1,441 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Networks.java | Networks | isInnerAddress | class Networks {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(Networks.class);
/**
* Checks the specified hostname is an inner address.
*
* @param host the specified hostname
* @return {@code true} if it is, returns {@code false} otherwise
*... |
try {
final int intAddress = ipToLong(host);
return ipToLong("0.0.0.0") >> 24 == intAddress >> 24 ||
ipToLong("127.0.0.1") >> 24 == intAddress >> 24 ||
ipToLong("10.0.0.0") >> 24 == intAddress >> 24 ||
ipToLong("172.16.0.0") >>... | 187 | 204 | 391 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Pangu.java | Pangu | spacingText | class Pangu {
/**
* You should use the constructor to create a {@code Pangu} object with default values.
*/
public Pangu() {
}
/*
* Some capturing group patterns for convenience.
*
* CJK: Chinese, Japanese, Korean
* ANS: Alphabet, Number, Symbol
*/
private static... |
// CJK and quotes
Matcher cqMatcher = CJK_QUOTE.matcher(text);
text = cqMatcher.replaceAll("$1 $2");
Matcher qcMatcher = QUOTE_CJK.matcher(text);
text = qcMatcher.replaceAll("$1 $2");
Matcher fixQuoteMatcher = FIX_QUOTE.matcher(text);
text = fixQuoteMatcher.rep... | 1,260 | 514 | 1,774 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Results.java | Results | newFail | class Results {
/**
* Constructs a successful result.
*
* @return result
*/
public static JSONObject newSucc() {
return new JSONObject().put(Keys.CODE, StatusCodes.SUCC).put(Keys.MSG, "");
}
/**
* Constructs a failed result.
*
* @return result
*/
pub... |
return new JSONObject().put(Keys.CODE, StatusCodes.ERR).put(Keys.MSG, "System is abnormal, please try again later");
| 143 | 40 | 183 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Runes.java | Runes | getChinesePercent | class Runes {
private Runes() {
}
// public static void main(final String[] args) {
// System.out.println(getChinesePercent("123abc这个中文cde123abc也要提取123ab"));
// }
/**
* Removes control characters for the specified string.
*
* @param str the specified string
* @return str... |
if (StringUtils.isBlank(str)) {
return 0;
}
final Pattern p = Pattern.compile("([\u4e00-\u9fa5]+)");
final Matcher m = p.matcher(str);
final StringBuilder chineseBuilder = new StringBuilder();
while (m.find()) {
chineseBuilder.append(m.group(0));... | 285 | 147 | 432 | <no_super_class> |
88250_symphony | symphony/src/main/java/org/b3log/symphony/util/Tesseracts.java | Tesseracts | recognizeCharacter | class Tesseracts {
/**
* Recognizes a single character from the specified image file path.
*
* @param imagePath the specified image file path
* @return the recognized character
*/
public static String recognizeCharacter(final String imagePath) {<FILL_FUNCTION_BODY>}
/**
* Pri... |
try {
Execs.exec(new String[]{"sh", "-c", "tesseract " + imagePath + " " + imagePath + " -l chi_sim --psm 8"}, 1000 * 3);
return StringUtils.trim(IOUtils.toString(new FileInputStream(imagePath + ".txt"), StandardCharsets.UTF_8));
} catch (final Exception e) {
return ... | 108 | 109 | 217 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/beakerx/src/main/java/tech/tablesaw/beakerx/TablesawDisplayer.java | TablesawDisplayer | registerColumns | class TablesawDisplayer {
private TablesawDisplayer() {}
/**
* Registers {@link Table} and {@link Column} for display in Jupyter. Call {@link
* #registerTable()} or {@link #registerColumns()} instead if you'd like to only display one or
* the other.
*/
public static void register() {
registerTab... |
Displayers.register(
Column.class,
new Displayer<Column>() {
@Override
public Map<String, String> display(Column column) {
new TableDisplay(
column.size(),
1,
Lists.newArrayList(column.name()),
... | 397 | 124 | 521 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/aggregate/NumericAggregateFunction.java | NumericAggregateFunction | isCompatibleColumn | class NumericAggregateFunction extends AggregateFunction<NumericColumn<?>, Double> {
/**
* Constructs a NumericAggregateFunction with the given name. The name may be used to name a
* column in the output when this function is used by {@link Summarizer}
*/
public NumericAggregateFunction(String name) {
... |
return type.equals(ColumnType.DOUBLE)
|| type.equals(ColumnType.FLOAT)
|| type.equals(ColumnType.INTEGER)
|| type.equals(ColumnType.SHORT)
|| type.equals(ColumnType.LONG);
| 174 | 71 | 245 | <methods>public void <init>(java.lang.String) ,public java.lang.String functionName() ,public abstract boolean isCompatibleColumn(tech.tablesaw.api.ColumnType) ,public abstract tech.tablesaw.api.ColumnType returnType() ,public abstract java.lang.Double summarize(NumericColumn<?>) ,public java.lang.String toString() <va... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/aggregate/PivotTable.java | PivotTable | pivot | class PivotTable {
/**
* Returns a table that is a rotation of the given table pivoted around the key columns, and
* filling the output cells using the values calculated by the {@code aggregateFunction} when
* applied to the {@code values column} grouping by the key columns
*
* @param table The table ... |
TableSliceGroup tsg = table.splitOn(column1);
Table pivotTable = Table.create("Pivot: " + column1.name() + " x " + column2.name());
pivotTable.addColumns(column1.type().create(column1.name()));
List<String> valueColumnNames = getValueColumnNames(table, column2);
for (String colName : valueColum... | 619 | 357 | 976 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/analytic/AnalyticQueryEngine.java | AnalyticQueryEngine | processNumberingFunctions | class AnalyticQueryEngine {
private final AnalyticQuery query;
private final Table destination;
private final IntComparatorChain rowComparator;
private AnalyticQueryEngine(AnalyticQuery query) {
this.query = query;
this.destination = Table.create("Analytic ~ " + query.getTable().name());
Optional<S... |
for (String toColumn : query.getArgumentList().getNumberingFunctions().keySet()) {
if (rowComparator == null) {
throw new IllegalArgumentException("Cannot use Numbering Function without OrderBy");
}
FunctionCall<NumberingFunctions> functionCall =
query.getArgumentList().getNumbe... | 978 | 364 | 1,342 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/analytic/ArgumentList.java | ArgumentList | toSqlString | class ArgumentList {
// Throws if a column with the same name is registered
private final Map<String, FunctionCall<AggregateFunctions>> aggregateFunctions;
private final Map<String, FunctionCall<NumberingFunctions>> numberingFunctions;
// Used to determine the order in which to add new columns.
private final... |
StringBuilder sb = new StringBuilder();
int colCount = 0;
for (String newColName : newColumnNames) {
String optionalNumberingCol =
Optional.ofNullable(numberingFunctions.get(newColName))
.map(f -> f.toSqlString(windowName))
.orElse("");
String optionalAggre... | 1,774 | 213 | 1,987 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/analytic/WindowSlider.java | WindowSlider | slideRightStrategy | class WindowSlider {
private final boolean mirrored;
private final WindowGrowthType windowGrowthType;
private final int initialLeftBound;
private final int initialRightBound;
@SuppressWarnings({"unchecked", "rawtypes"})
private final AggregateFunction function;
private final TableSlice slice;
private ... |
switch (this.windowGrowthType) {
case FIXED:
return i -> i;
case FIXED_LEFT:
case SLIDING:
return i -> i + 1;
}
throw new IllegalArgumentException("Unexpected growthType: " + this.windowGrowthType);
| 1,657 | 84 | 1,741 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/analytic/WindowSpecification.java | WindowSpecification | formatOrdering | class WindowSpecification {
private final String windowName;
private final Set<String> partitionColumns;
private final Sort sort;
private WindowSpecification(String windowName, Set<String> partitionColumns, Sort sort) {
this.windowName = windowName;
this.partitionColumns = partitionColumns;
this.s... |
String formattedOrder = "ASC";
if (sortEntry.getValue() == Sort.Order.DESCEND) {
formattedOrder = "DESC";
}
return sortEntry.getKey() + " " + formattedOrder;
| 761 | 60 | 821 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/api/NumberColumn.java | NumberColumn | set | class NumberColumn<C extends NumberColumn<C, T>, T extends Number>
extends AbstractColumn<C, T> implements NumericColumn<T> {
private NumberColumnFormatter printFormatter = new NumberColumnFormatter();
protected Locale locale;
protected final IntComparator comparator =
(r1, r2) -> {
final dou... |
for (int row = 0; row < size(); row++) {
if (condition.test(getDouble(row))) {
set(row, other.get(row));
}
}
return this;
| 1,135 | 57 | 1,192 | <methods>public void <init>(tech.tablesaw.api.ColumnType, java.lang.String, AbstractColumnParser<T>) ,public tech.tablesaw.api.StringColumn asStringColumn() ,public abstract Column<T> emptyCopy() ,public C filter(Predicate<? super T>) ,public C first(int) ,public C inRange(int, int) ,public int indexOf(java.lang.Object... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/AbstractColumn.java | AbstractColumn | lastIndexOf | class AbstractColumn<C extends Column<T>, T> implements Column<T> {
public static final int DEFAULT_ARRAY_SIZE = 128;
private String name;
private final ColumnType type;
private AbstractColumnParser<T> parser;
/**
* Constructs a column with the given {@link ColumnType}, name, and {@link AbstractColumn... |
return IntStream.iterate(size() - 1, i -> (i >= 0), i -> i - 1).filter(i -> get(i).equals(o))
.findFirst().orElse(-1);
| 1,445 | 59 | 1,504 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/AbstractColumnParser.java | AbstractColumnParser | remove | class AbstractColumnParser<T> {
private final ColumnType columnType;
protected List<String> missingValueStrings = TypeUtils.MISSING_INDICATORS;
public AbstractColumnParser(ColumnType columnType) {
this.columnType = columnType;
}
public abstract boolean canParse(String s);
public abstract T parse(St... |
if (str == null || str.indexOf(remove) == -1) {
return str;
}
final char[] chars = str.toCharArray();
int pos = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] != remove) {
chars[pos++] = chars[i];
}
}
return new String(chars, 0, pos);
| 515 | 119 | 634 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/AbstractColumnType.java | AbstractColumnType | equals | class AbstractColumnType implements ColumnType {
private final int byteSize;
private final String name;
private final String printerFriendlyName;
protected AbstractColumnType(int byteSize, String name, String printerFriendlyName) {
this.byteSize = byteSize;
this.name = name;
this.printerFriendly... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractColumnType that = (AbstractColumnType) o;
return byteSize == that.byteSize
&& Objects.equal(name, that.name)
&& Objects.equal(printerFriendlyName, that.printerFriendlyName);
| 303 | 95 | 398 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/SkipColumnType.java | SkipColumnType | create | class SkipColumnType extends AbstractColumnType {
private static SkipColumnType INSTANCE;
private SkipColumnType(int byteSize, String name, String printerFriendlyName) {
super(byteSize, name, printerFriendlyName);
}
/** Returns the singleton instance of this class */
public static SkipColumnType instan... |
throw new UnsupportedOperationException(
"Column type " + name() + " doesn't support column creation");
| 300 | 30 | 330 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/booleans/BooleanColumnType.java | BooleanColumnType | instance | class BooleanColumnType extends AbstractColumnType {
public static final BooleanParser DEFAULT_PARSER = new BooleanParser(ColumnType.BOOLEAN);
public static final byte MISSING_VALUE = (Byte) missingValueIndicator();
public static final byte BYTE_TRUE = 1;
public static final byte BYTE_FALSE = 0;
private s... |
if (INSTANCE == null) {
INSTANCE = new BooleanColumnType(BYTE_SIZE, "BOOLEAN", "Boolean");
}
return INSTANCE;
| 290 | 48 | 338 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/booleans/BooleanFormatter.java | BooleanFormatter | format | class BooleanFormatter extends ColumnFormatter {
private String trueString = "true";
private String falseString = "false";
public BooleanFormatter(String trueString, String falseString, String missingString) {
super(missingString);
this.trueString = trueString;
this.falseString = falseString;
}
... |
if (value == BooleanColumnType.MISSING_VALUE) {
return getMissingString();
}
if (value == (byte) 1) {
return trueString;
}
return falseString;
| 317 | 58 | 375 | <methods>public java.lang.String getMissingString() <variables>private final non-sealed java.lang.String missingString |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/booleans/BooleanParser.java | BooleanParser | parse | class BooleanParser extends AbstractColumnParser<Boolean> {
// A more restricted set of 'false' strings that is used for column type detection
private static final List<String> FALSE_STRINGS_FOR_DETECTION =
Arrays.asList("F", "f", "N", "n", "FALSE", "false", "False");
// A more restricted set of 'true' st... |
if (isMissing(s)) {
return null;
} else if (TRUE_STRINGS.contains(s)) {
return true;
} else if (FALSE_STRINGS.contains(s)) {
return false;
} else {
throw new IllegalArgumentException(
"Attempting to convert non-boolean value " + s + " to Boolean");
}
| 590 | 95 | 685 | <methods>public void <init>(tech.tablesaw.api.ColumnType) ,public abstract boolean canParse(java.lang.String) ,public tech.tablesaw.api.ColumnType columnType() ,public boolean isMissing(java.lang.String) ,public abstract java.lang.Boolean parse(java.lang.String) ,public byte parseByte(java.lang.String) ,public double p... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/booleans/fillers/BooleanIterable.java | BooleanIterable | iterator | class BooleanIterable implements it.unimi.dsi.fastutil.booleans.BooleanIterable {
private final long bits;
private final int length;
private BooleanIterable(final long bits, final int length) {
this.bits = bits;
this.length = length;
}
public static BooleanIterable bits(final long bits, final int l... |
return new BooleanIterator() {
int num = 0;
boolean next = bit(num);
private boolean bit(final int num) {
return ((bits >> (length - num - 1)) & 1) == 1;
}
@Override
public boolean hasNext() {
return (num < length);
}
@Override
public boole... | 139 | 134 | 273 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/dates/DateColumnFormatter.java | DateColumnFormatter | format | class DateColumnFormatter extends TemporalColumnFormatter {
public DateColumnFormatter(DateTimeFormatter format) {
super(format);
}
public DateColumnFormatter() {
super();
}
public DateColumnFormatter(DateTimeFormatter format, String missingValueString) {
super(format, missingValueString);
}
... |
if (value == DateColumnType.missingValueIndicator()) {
return getMissingString();
}
if (getFormat() == null) {
return toDateString(value);
}
LocalDate date = asLocalDate(value);
if (date == null) {
return "";
}
return getFormat().format(date);
| 177 | 92 | 269 | <methods>public java.time.format.DateTimeFormatter getFormat() <variables>private final non-sealed java.time.format.DateTimeFormatter format |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/dates/DateColumnType.java | DateColumnType | instance | class DateColumnType extends AbstractColumnType {
public static final int BYTE_SIZE = 4;
public static final DateParser DEFAULT_PARSER = new DateParser(ColumnType.LOCAL_DATE);
private static DateColumnType INSTANCE;
private DateColumnType(int byteSize, String name, String printerFriendlyName) {
super(byt... |
if (INSTANCE == null) {
INSTANCE = new DateColumnType(BYTE_SIZE, "LOCAL_DATE", "Date");
}
return INSTANCE;
| 243 | 48 | 291 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/dates/DateParser.java | DateParser | parse | class DateParser extends AbstractColumnParser<LocalDate> {
// Formats that we accept in parsing dates from strings
private static final DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyyMMdd");
private static final DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("MM/dd/yyyy");
private static final... |
if (isMissing(s)) {
return null;
}
return LocalDate.parse(s, formatter);
| 1,170 | 34 | 1,204 | <methods>public void <init>(tech.tablesaw.api.ColumnType) ,public abstract boolean canParse(java.lang.String) ,public tech.tablesaw.api.ColumnType columnType() ,public boolean isMissing(java.lang.String) ,public abstract java.time.LocalDate parse(java.lang.String) ,public byte parseByte(java.lang.String) ,public double... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/datetimes/DateTimeColumnFormatter.java | DateTimeColumnFormatter | format | class DateTimeColumnFormatter {
private final DateTimeFormatter format;
private String missingValueString = "";
public DateTimeColumnFormatter() {
this.format = null;
}
public DateTimeColumnFormatter(DateTimeFormatter format) {
this.format = format;
}
public DateTimeColumnFormatter(DateTimeFor... |
if (value == DateTimeColumnType.missingValueIndicator()) {
return missingValueString;
}
if (format == null) {
return PackedLocalDateTime.toString(value);
}
LocalDateTime time = asLocalDateTime(value);
if (time == null) {
return "";
}
return format.format(time);
| 204 | 92 | 296 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/datetimes/DateTimeColumnType.java | DateTimeColumnType | instance | class DateTimeColumnType extends AbstractColumnType {
public static final int BYTE_SIZE = 8;
public static final DateTimeParser DEFAULT_PARSER =
new DateTimeParser(ColumnType.LOCAL_DATE_TIME);
private static DateTimeColumnType INSTANCE =
new DateTimeColumnType(BYTE_SIZE, "LOCAL_DATE_TIME", "DateTim... |
if (INSTANCE == null) {
INSTANCE = new DateTimeColumnType(BYTE_SIZE, "LOCAL_DATE_TIME", "DateTime");
}
return INSTANCE;
| 266 | 50 | 316 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/datetimes/DateTimeParser.java | DateTimeParser | canParse | class DateTimeParser extends AbstractColumnParser<LocalDateTime> {
private static final DateTimeFormatter dtTimef0 =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 2014-07-09 13:03:44
private static final DateTimeFormatter dtTimef2 =
DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm:ss.S... |
if (isMissing(s)) {
return true;
}
try {
LocalDateTime.parse(s, formatter.withLocale(locale));
return true;
} catch (DateTimeParseException e) {
// it's all part of the plan
return false;
}
| 1,045 | 78 | 1,123 | <methods>public void <init>(tech.tablesaw.api.ColumnType) ,public abstract boolean canParse(java.lang.String) ,public tech.tablesaw.api.ColumnType columnType() ,public boolean isMissing(java.lang.String) ,public abstract java.time.LocalDateTime parse(java.lang.String) ,public byte parseByte(java.lang.String) ,public do... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/instant/InstantColumnFormatter.java | InstantColumnFormatter | format | class InstantColumnFormatter extends TemporalColumnFormatter {
private final ZoneId zoneId;
public InstantColumnFormatter() {
super(null);
this.zoneId = ZoneOffset.UTC;
}
public InstantColumnFormatter(ZoneId zoneId) {
super(null);
this.zoneId = zoneId;
}
public InstantColumnFormatter(Dat... |
if (value == InstantColumnType.missingValueIndicator()) {
return getMissingString();
}
if (getFormat() == null) {
return PackedInstant.toString(value);
}
Instant instant = PackedInstant.asInstant(value);
if (instant == null) {
return "";
}
ZonedDateTime time = instant.... | 360 | 117 | 477 | <methods>public java.time.format.DateTimeFormatter getFormat() <variables>private final non-sealed java.time.format.DateTimeFormatter format |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/instant/InstantColumnType.java | InstantColumnType | instance | class InstantColumnType extends AbstractColumnType {
public static final int BYTE_SIZE = 8;
public static final InstantParser DEFAULT_PARSER = new InstantParser(ColumnType.INSTANT);
private static InstantColumnType INSTANCE =
new InstantColumnType(BYTE_SIZE, "INSTANT", "Instant");
private InstantColum... |
if (INSTANCE == null) {
INSTANCE = new InstantColumnType(BYTE_SIZE, "INSTANT", "Instant");
}
return INSTANCE;
| 266 | 48 | 314 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/instant/InstantParser.java | InstantParser | canParse | class InstantParser extends AbstractColumnParser<Instant> {
public InstantParser(ColumnType columnType) {
super(columnType);
}
@Override
public boolean canParse(String s) {<FILL_FUNCTION_BODY>}
@Override
public Instant parse(String value) {
return Instant.parse(value);
}
} |
if (isMissing(s)) {
return true;
}
try {
parse(s);
return true;
} catch (RuntimeException e) {
return false;
}
| 97 | 54 | 151 | <methods>public void <init>(tech.tablesaw.api.ColumnType) ,public abstract boolean canParse(java.lang.String) ,public tech.tablesaw.api.ColumnType columnType() ,public boolean isMissing(java.lang.String) ,public abstract java.time.Instant parse(java.lang.String) ,public byte parseByte(java.lang.String) ,public double p... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/instant/PackedInstant.java | PackedInstant | asInstant | class PackedInstant {
protected PackedInstant() {}
public static Instant asInstant(long dateTime) {<FILL_FUNCTION_BODY>}
protected static long pack(LocalDate date, LocalTime time) {
if (date == null || time == null) {
return missingValueIndicator();
}
int d = PackedLocalDate.pack(date);
i... |
if (dateTime == missingValueIndicator()) {
return null;
}
int date = date(dateTime);
int time = time(dateTime);
LocalDate d = PackedLocalDate.asLocalDate(date);
LocalTime t = PackedLocalTime.asLocalTime(time);
if (d == null || t == null) {
return null;
}
return LocalDate... | 1,243 | 122 | 1,365 | <no_super_class> |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/numbers/DoubleColumnType.java | DoubleColumnType | instance | class DoubleColumnType extends AbstractColumnType {
private static final int BYTE_SIZE = 8;
/** Returns the default parser for DoubleColumn */
public static final DoubleParser DEFAULT_PARSER = new DoubleParser(ColumnType.DOUBLE);
private static DoubleColumnType INSTANCE = new DoubleColumnType(BYTE_SIZE, "DOU... |
if (INSTANCE == null) {
INSTANCE = new DoubleColumnType(BYTE_SIZE, "DOUBLE", "Double");
}
return INSTANCE;
| 362 | 47 | 409 | <methods>public int byteSize() ,public boolean equals(java.lang.Object) ,public java.lang.String getPrinterFriendlyName() ,public int hashCode() ,public java.lang.String name() ,public java.lang.String toString() <variables>private final non-sealed int byteSize,private final non-sealed java.lang.String name,private fin... |
jtablesaw_tablesaw | tablesaw/core/src/main/java/tech/tablesaw/columns/numbers/DoubleParser.java | DoubleParser | isPercent | class DoubleParser extends AbstractColumnParser<Double> {
public DoubleParser(ColumnType columnType) {
super(columnType);
}
public DoubleParser(DoubleColumnType doubleColumnType, ReadOptions readOptions) {
super(doubleColumnType);
if (readOptions.missingValueIndicators().length > 0) {
missingV... |
boolean containsPercentSymbol = s.charAt(s.length() - 1) == '%';
if (containsPercentSymbol) {
String percentageValue = s.substring(0, s.length() - 1);
try {
double value = Double.parseDouble(percentageValue);
return !Double.isNaN(value);
} catch (NumberFormatException e) {
... | 536 | 126 | 662 | <methods>public void <init>(tech.tablesaw.api.ColumnType) ,public abstract boolean canParse(java.lang.String) ,public tech.tablesaw.api.ColumnType columnType() ,public boolean isMissing(java.lang.String) ,public abstract java.lang.Double parse(java.lang.String) ,public byte parseByte(java.lang.String) ,public double pa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.