id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
153,200
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.getTopicForTopicNode
protected TopicWrapper getTopicForTopicNode(final DataProviderFactory providerFactory, final ITopicNode topicNode) { TopicWrapper topic = null; if (topicNode.isTopicANewTopic()) { topic = getTopicForNewTopicNode(providerFactory, topicNode); } else if (topicNode.isTopicAClonedTopic()) { topic = ProcessorUtilities.cloneTopic(providerFactory, topicNode, serverEntities); } else if (topicNode.isTopicAnExistingTopic()) { topic = getTopicForExistingTopicNode(providerFactory, topicNode); } return topic; }
java
protected TopicWrapper getTopicForTopicNode(final DataProviderFactory providerFactory, final ITopicNode topicNode) { TopicWrapper topic = null; if (topicNode.isTopicANewTopic()) { topic = getTopicForNewTopicNode(providerFactory, topicNode); } else if (topicNode.isTopicAClonedTopic()) { topic = ProcessorUtilities.cloneTopic(providerFactory, topicNode, serverEntities); } else if (topicNode.isTopicAnExistingTopic()) { topic = getTopicForExistingTopicNode(providerFactory, topicNode); } return topic; }
[ "protected", "TopicWrapper", "getTopicForTopicNode", "(", "final", "DataProviderFactory", "providerFactory", ",", "final", "ITopicNode", "topicNode", ")", "{", "TopicWrapper", "topic", "=", "null", ";", "if", "(", "topicNode", ".", "isTopicANewTopic", "(", ")", ")", "{", "topic", "=", "getTopicForNewTopicNode", "(", "providerFactory", ",", "topicNode", ")", ";", "}", "else", "if", "(", "topicNode", ".", "isTopicAClonedTopic", "(", ")", ")", "{", "topic", "=", "ProcessorUtilities", ".", "cloneTopic", "(", "providerFactory", ",", "topicNode", ",", "serverEntities", ")", ";", "}", "else", "if", "(", "topicNode", ".", "isTopicAnExistingTopic", "(", ")", ")", "{", "topic", "=", "getTopicForExistingTopicNode", "(", "providerFactory", ",", "topicNode", ")", ";", "}", "return", "topic", ";", "}" ]
Gets or creates the underlying Topic Entity for a spec topic. @param providerFactory @param topicNode The spec topic to get the topic entity for. @return The topic entity if one could be found, otherwise null.
[ "Gets", "or", "creates", "the", "underlying", "Topic", "Entity", "for", "a", "spec", "topic", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L628-L640
153,201
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.processTopicTags
protected boolean processTopicTags(final TagProvider tagProvider, final ITopicNode specTopic, final TopicWrapper topic) { LOG.debug("Processing topic tags"); boolean changed = false; // Get the tags for the topic final List<String> addTagNames = specTopic.getTags(true); final List<TagWrapper> addTags = new ArrayList<TagWrapper>(); for (final String addTagName : addTagNames) { final TagWrapper tag = tagProvider.getTagByName(addTagName); if (tag != null) { addTags.add(tag); } } // Check if the app should be shutdown if (isShuttingDown.get()) { return changed; } // Process the tags depending on the topic type if (specTopic.isTopicAClonedTopic()) { if (processClonedTopicTags(tagProvider, specTopic, topic, addTags)) changed = true; } else if (specTopic.isTopicAnExistingTopic() && specTopic.getRevision() == null) { if (processExistingTopicTags(tagProvider, topic, addTags)) changed = true; } else if (specTopic.isTopicANewTopic()) { if (processNewTopicTags(tagProvider, topic, addTags)) changed = true; } return changed; }
java
protected boolean processTopicTags(final TagProvider tagProvider, final ITopicNode specTopic, final TopicWrapper topic) { LOG.debug("Processing topic tags"); boolean changed = false; // Get the tags for the topic final List<String> addTagNames = specTopic.getTags(true); final List<TagWrapper> addTags = new ArrayList<TagWrapper>(); for (final String addTagName : addTagNames) { final TagWrapper tag = tagProvider.getTagByName(addTagName); if (tag != null) { addTags.add(tag); } } // Check if the app should be shutdown if (isShuttingDown.get()) { return changed; } // Process the tags depending on the topic type if (specTopic.isTopicAClonedTopic()) { if (processClonedTopicTags(tagProvider, specTopic, topic, addTags)) changed = true; } else if (specTopic.isTopicAnExistingTopic() && specTopic.getRevision() == null) { if (processExistingTopicTags(tagProvider, topic, addTags)) changed = true; } else if (specTopic.isTopicANewTopic()) { if (processNewTopicTags(tagProvider, topic, addTags)) changed = true; } return changed; }
[ "protected", "boolean", "processTopicTags", "(", "final", "TagProvider", "tagProvider", ",", "final", "ITopicNode", "specTopic", ",", "final", "TopicWrapper", "topic", ")", "{", "LOG", ".", "debug", "(", "\"Processing topic tags\"", ")", ";", "boolean", "changed", "=", "false", ";", "// Get the tags for the topic", "final", "List", "<", "String", ">", "addTagNames", "=", "specTopic", ".", "getTags", "(", "true", ")", ";", "final", "List", "<", "TagWrapper", ">", "addTags", "=", "new", "ArrayList", "<", "TagWrapper", ">", "(", ")", ";", "for", "(", "final", "String", "addTagName", ":", "addTagNames", ")", "{", "final", "TagWrapper", "tag", "=", "tagProvider", ".", "getTagByName", "(", "addTagName", ")", ";", "if", "(", "tag", "!=", "null", ")", "{", "addTags", ".", "add", "(", "tag", ")", ";", "}", "}", "// Check if the app should be shutdown", "if", "(", "isShuttingDown", ".", "get", "(", ")", ")", "{", "return", "changed", ";", "}", "// Process the tags depending on the topic type", "if", "(", "specTopic", ".", "isTopicAClonedTopic", "(", ")", ")", "{", "if", "(", "processClonedTopicTags", "(", "tagProvider", ",", "specTopic", ",", "topic", ",", "addTags", ")", ")", "changed", "=", "true", ";", "}", "else", "if", "(", "specTopic", ".", "isTopicAnExistingTopic", "(", ")", "&&", "specTopic", ".", "getRevision", "(", ")", "==", "null", ")", "{", "if", "(", "processExistingTopicTags", "(", "tagProvider", ",", "topic", ",", "addTags", ")", ")", "changed", "=", "true", ";", "}", "else", "if", "(", "specTopic", ".", "isTopicANewTopic", "(", ")", ")", "{", "if", "(", "processNewTopicTags", "(", "tagProvider", ",", "topic", ",", "addTags", ")", ")", "changed", "=", "true", ";", "}", "return", "changed", ";", "}" ]
Process a Spec Topic and add or remove tags defined by the spec topic. @param tagProvider @param specTopic The spec topic that represents the changes to the topic. @param topic The topic entity to be updated. @return True if anything in the topic entity was changed, otherwise false.
[ "Process", "a", "Spec", "Topic", "and", "add", "or", "remove", "tags", "defined", "by", "the", "spec", "topic", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L758-L787
153,202
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.processAssignedWriter
protected void processAssignedWriter(final TagProvider tagProvider, final ITopicNode topicNode, final TopicWrapper topic) { LOG.debug("Processing assigned writer"); // See if a new tag collection needs to be created if (topic.getTags() == null) { topic.setTags(tagProvider.newTagCollection()); } // Set the assigned writer (Tag Table) final TagWrapper writerTag = tagProvider.getTagByName(topicNode.getAssignedWriter(true)); // Save a new assigned writer topic.getTags().addNewItem(writerTag); // Some providers need the collection to be set to set flags for saving topic.setTags(topic.getTags()); }
java
protected void processAssignedWriter(final TagProvider tagProvider, final ITopicNode topicNode, final TopicWrapper topic) { LOG.debug("Processing assigned writer"); // See if a new tag collection needs to be created if (topic.getTags() == null) { topic.setTags(tagProvider.newTagCollection()); } // Set the assigned writer (Tag Table) final TagWrapper writerTag = tagProvider.getTagByName(topicNode.getAssignedWriter(true)); // Save a new assigned writer topic.getTags().addNewItem(writerTag); // Some providers need the collection to be set to set flags for saving topic.setTags(topic.getTags()); }
[ "protected", "void", "processAssignedWriter", "(", "final", "TagProvider", "tagProvider", ",", "final", "ITopicNode", "topicNode", ",", "final", "TopicWrapper", "topic", ")", "{", "LOG", ".", "debug", "(", "\"Processing assigned writer\"", ")", ";", "// See if a new tag collection needs to be created", "if", "(", "topic", ".", "getTags", "(", ")", "==", "null", ")", "{", "topic", ".", "setTags", "(", "tagProvider", ".", "newTagCollection", "(", ")", ")", ";", "}", "// Set the assigned writer (Tag Table)", "final", "TagWrapper", "writerTag", "=", "tagProvider", ".", "getTagByName", "(", "topicNode", ".", "getAssignedWriter", "(", "true", ")", ")", ";", "// Save a new assigned writer", "topic", ".", "getTags", "(", ")", ".", "addNewItem", "(", "writerTag", ")", ";", "// Some providers need the collection to be set to set flags for saving", "topic", ".", "setTags", "(", "topic", ".", "getTags", "(", ")", ")", ";", "}" ]
Processes a Spec Topic and adds the assigned writer for the topic it represents. @param tagProvider @param topicNode The topic node object that contains the assigned writer. @param topic The topic entity to be updated. @return True if anything in the topic entity was changed, otherwise false.
[ "Processes", "a", "Spec", "Topic", "and", "adds", "the", "assigned", "writer", "for", "the", "topic", "it", "represents", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L936-L950
153,203
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.processTopicSourceUrls
protected boolean processTopicSourceUrls(final TopicSourceURLProvider topicSourceURLProvider, final SpecTopic specTopic, final TopicWrapper topic) { LOG.debug("Processing topic source urls"); boolean changed = false; // Save the new Source Urls final List<String> urls = specTopic.getSourceUrls(true); if (urls != null && !urls.isEmpty()) { final UpdateableCollectionWrapper<TopicSourceURLWrapper> sourceUrls = topic.getSourceURLs() == null ? topicSourceURLProvider .newTopicSourceURLCollection(topic) : topic.getSourceURLs(); // Iterate over the spec topic urls and add them for (final String url : urls) { final TopicSourceURLWrapper sourceUrl = topicSourceURLProvider.newTopicSourceURL(topic); sourceUrl.setUrl(url); sourceUrls.addNewItem(sourceUrl); } topic.setSourceURLs(sourceUrls); changed = true; } return changed; }
java
protected boolean processTopicSourceUrls(final TopicSourceURLProvider topicSourceURLProvider, final SpecTopic specTopic, final TopicWrapper topic) { LOG.debug("Processing topic source urls"); boolean changed = false; // Save the new Source Urls final List<String> urls = specTopic.getSourceUrls(true); if (urls != null && !urls.isEmpty()) { final UpdateableCollectionWrapper<TopicSourceURLWrapper> sourceUrls = topic.getSourceURLs() == null ? topicSourceURLProvider .newTopicSourceURLCollection(topic) : topic.getSourceURLs(); // Iterate over the spec topic urls and add them for (final String url : urls) { final TopicSourceURLWrapper sourceUrl = topicSourceURLProvider.newTopicSourceURL(topic); sourceUrl.setUrl(url); sourceUrls.addNewItem(sourceUrl); } topic.setSourceURLs(sourceUrls); changed = true; } return changed; }
[ "protected", "boolean", "processTopicSourceUrls", "(", "final", "TopicSourceURLProvider", "topicSourceURLProvider", ",", "final", "SpecTopic", "specTopic", ",", "final", "TopicWrapper", "topic", ")", "{", "LOG", ".", "debug", "(", "\"Processing topic source urls\"", ")", ";", "boolean", "changed", "=", "false", ";", "// Save the new Source Urls", "final", "List", "<", "String", ">", "urls", "=", "specTopic", ".", "getSourceUrls", "(", "true", ")", ";", "if", "(", "urls", "!=", "null", "&&", "!", "urls", ".", "isEmpty", "(", ")", ")", "{", "final", "UpdateableCollectionWrapper", "<", "TopicSourceURLWrapper", ">", "sourceUrls", "=", "topic", ".", "getSourceURLs", "(", ")", "==", "null", "?", "topicSourceURLProvider", ".", "newTopicSourceURLCollection", "(", "topic", ")", ":", "topic", ".", "getSourceURLs", "(", ")", ";", "// Iterate over the spec topic urls and add them", "for", "(", "final", "String", "url", ":", "urls", ")", "{", "final", "TopicSourceURLWrapper", "sourceUrl", "=", "topicSourceURLProvider", ".", "newTopicSourceURL", "(", "topic", ")", ";", "sourceUrl", ".", "setUrl", "(", "url", ")", ";", "sourceUrls", ".", "addNewItem", "(", "sourceUrl", ")", ";", "}", "topic", ".", "setSourceURLs", "(", "sourceUrls", ")", ";", "changed", "=", "true", ";", "}", "return", "changed", ";", "}" ]
Processes a Spec Topic and adds any new Source Urls to the topic it represents. @param topicSourceURLProvider @param specTopic The spec topic object that contains the urls to add. @param topic The topic entity to be updated. @return True if anything in the topic entity was changed, otherwise false.
[ "Processes", "a", "Spec", "Topic", "and", "adds", "any", "new", "Source", "Urls", "to", "the", "topic", "it", "represents", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L960-L985
153,204
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.syncDuplicatedTopics
protected void syncDuplicatedTopics(final Map<ITopicNode, ITopicNode> duplicatedTopics) { for (final Map.Entry<ITopicNode, ITopicNode> topicEntry : duplicatedTopics.entrySet()) { final ITopicNode topic = topicEntry.getKey(); final ITopicNode cloneTopic = topicEntry.getValue(); // Set the id topic.setId(cloneTopic.getDBId() == null ? null : cloneTopic.getDBId().toString()); } }
java
protected void syncDuplicatedTopics(final Map<ITopicNode, ITopicNode> duplicatedTopics) { for (final Map.Entry<ITopicNode, ITopicNode> topicEntry : duplicatedTopics.entrySet()) { final ITopicNode topic = topicEntry.getKey(); final ITopicNode cloneTopic = topicEntry.getValue(); // Set the id topic.setId(cloneTopic.getDBId() == null ? null : cloneTopic.getDBId().toString()); } }
[ "protected", "void", "syncDuplicatedTopics", "(", "final", "Map", "<", "ITopicNode", ",", "ITopicNode", ">", "duplicatedTopics", ")", "{", "for", "(", "final", "Map", ".", "Entry", "<", "ITopicNode", ",", "ITopicNode", ">", "topicEntry", ":", "duplicatedTopics", ".", "entrySet", "(", ")", ")", "{", "final", "ITopicNode", "topic", "=", "topicEntry", ".", "getKey", "(", ")", ";", "final", "ITopicNode", "cloneTopic", "=", "topicEntry", ".", "getValue", "(", ")", ";", "// Set the id", "topic", ".", "setId", "(", "cloneTopic", ".", "getDBId", "(", ")", "==", "null", "?", "null", ":", "cloneTopic", ".", "getDBId", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Syncs all duplicated topics with their real topic counterpart in the content specification. @param duplicatedTopics A Map of the all the duplicated topics in the Content Specification mapped to there bae topic.
[ "Syncs", "all", "duplicated", "topics", "with", "their", "real", "topic", "counterpart", "in", "the", "content", "specification", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1028-L1036
153,205
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.findExistingNode
protected CSNodeWrapper findExistingNode(final CSNodeWrapper parent, final Node childNode, final List<CSNodeWrapper> entityChildrenNodes) { CSNodeWrapper foundNodeEntity = null; if (entityChildrenNodes != null && !entityChildrenNodes.isEmpty()) { for (final CSNodeWrapper nodeEntity : entityChildrenNodes) { // ignore it if the parent doesn't match otherwise keep looking to see if we can find a better match if (!doesParentMatch(parent, nodeEntity.getParent())) { continue; } if (childNode instanceof Comment) { // Comments are handled differently to try and get the exact comment better, since its common for multiple comments // to be on the same level if (doesCommentMatch((Comment) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } } else if (childNode instanceof Level) { // Since levels might have other possible titles that are in the title threshold, // we need to keep looping to see if we can find something better if (doesLevelMatch((Level) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } // stop looking if the title matches otherwise keep looking to see if we can find a better match if (parent != null && foundNodeEntity != null && foundNodeEntity.getTitle().equals(((Level) childNode).getTitle())) { break; } } else { if (childNode instanceof SpecTopic && doesTopicMatch((SpecTopic) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof CommonContent && doesCommonContentMatch((CommonContent) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof KeyValueNode && doesMetaDataMatch((KeyValueNode<?>) childNode, nodeEntity)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof File && doesFileMatch((File) childNode, nodeEntity)) { foundNodeEntity = nodeEntity; } } } } return foundNodeEntity; }
java
protected CSNodeWrapper findExistingNode(final CSNodeWrapper parent, final Node childNode, final List<CSNodeWrapper> entityChildrenNodes) { CSNodeWrapper foundNodeEntity = null; if (entityChildrenNodes != null && !entityChildrenNodes.isEmpty()) { for (final CSNodeWrapper nodeEntity : entityChildrenNodes) { // ignore it if the parent doesn't match otherwise keep looking to see if we can find a better match if (!doesParentMatch(parent, nodeEntity.getParent())) { continue; } if (childNode instanceof Comment) { // Comments are handled differently to try and get the exact comment better, since its common for multiple comments // to be on the same level if (doesCommentMatch((Comment) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } } else if (childNode instanceof Level) { // Since levels might have other possible titles that are in the title threshold, // we need to keep looping to see if we can find something better if (doesLevelMatch((Level) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } // stop looking if the title matches otherwise keep looking to see if we can find a better match if (parent != null && foundNodeEntity != null && foundNodeEntity.getTitle().equals(((Level) childNode).getTitle())) { break; } } else { if (childNode instanceof SpecTopic && doesTopicMatch((SpecTopic) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof CommonContent && doesCommonContentMatch((CommonContent) childNode, nodeEntity, foundNodeEntity != null)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof KeyValueNode && doesMetaDataMatch((KeyValueNode<?>) childNode, nodeEntity)) { foundNodeEntity = nodeEntity; } else if (childNode instanceof File && doesFileMatch((File) childNode, nodeEntity)) { foundNodeEntity = nodeEntity; } } } } return foundNodeEntity; }
[ "protected", "CSNodeWrapper", "findExistingNode", "(", "final", "CSNodeWrapper", "parent", ",", "final", "Node", "childNode", ",", "final", "List", "<", "CSNodeWrapper", ">", "entityChildrenNodes", ")", "{", "CSNodeWrapper", "foundNodeEntity", "=", "null", ";", "if", "(", "entityChildrenNodes", "!=", "null", "&&", "!", "entityChildrenNodes", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "final", "CSNodeWrapper", "nodeEntity", ":", "entityChildrenNodes", ")", "{", "// ignore it if the parent doesn't match otherwise keep looking to see if we can find a better match", "if", "(", "!", "doesParentMatch", "(", "parent", ",", "nodeEntity", ".", "getParent", "(", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "childNode", "instanceof", "Comment", ")", "{", "// Comments are handled differently to try and get the exact comment better, since its common for multiple comments", "// to be on the same level", "if", "(", "doesCommentMatch", "(", "(", "Comment", ")", "childNode", ",", "nodeEntity", ",", "foundNodeEntity", "!=", "null", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "}", "else", "if", "(", "childNode", "instanceof", "Level", ")", "{", "// Since levels might have other possible titles that are in the title threshold,", "// we need to keep looping to see if we can find something better", "if", "(", "doesLevelMatch", "(", "(", "Level", ")", "childNode", ",", "nodeEntity", ",", "foundNodeEntity", "!=", "null", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "// stop looking if the title matches otherwise keep looking to see if we can find a better match", "if", "(", "parent", "!=", "null", "&&", "foundNodeEntity", "!=", "null", "&&", "foundNodeEntity", ".", "getTitle", "(", ")", ".", "equals", "(", "(", "(", "Level", ")", "childNode", ")", ".", "getTitle", "(", ")", ")", ")", "{", "break", ";", "}", "}", "else", "{", "if", "(", "childNode", "instanceof", "SpecTopic", "&&", "doesTopicMatch", "(", "(", "SpecTopic", ")", "childNode", ",", "nodeEntity", ",", "foundNodeEntity", "!=", "null", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "else", "if", "(", "childNode", "instanceof", "CommonContent", "&&", "doesCommonContentMatch", "(", "(", "CommonContent", ")", "childNode", ",", "nodeEntity", ",", "foundNodeEntity", "!=", "null", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "else", "if", "(", "childNode", "instanceof", "KeyValueNode", "&&", "doesMetaDataMatch", "(", "(", "KeyValueNode", "<", "?", ">", ")", "childNode", ",", "nodeEntity", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "else", "if", "(", "childNode", "instanceof", "File", "&&", "doesFileMatch", "(", "(", "File", ")", "childNode", ",", "nodeEntity", ")", ")", "{", "foundNodeEntity", "=", "nodeEntity", ";", "}", "}", "}", "}", "return", "foundNodeEntity", ";", "}" ]
Finds the existing Entity Node that matches a ContentSpec node. @param childNode The ContentSpec node to find a matching Entity node for. @param entityChildrenNodes The entity child nodes to match from. @return The matching entity if one exists, otherwise null.
[ "Finds", "the", "existing", "Entity", "Node", "that", "matches", "a", "ContentSpec", "node", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1518-L1561
153,206
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesParentMatch
protected boolean doesParentMatch(final CSNodeWrapper parent, final CSNodeWrapper entityParent) { if (parent != null && entityParent != null) { if (parent.getId() != null && parent.getId().equals(entityParent.getId())) { return true; } else if (parent.getId() == null && entityParent.getId() == null && parent == entityParent) { return true; } else { return false; } } else if (parent == null && entityParent == null) { return true; } else { return false; } }
java
protected boolean doesParentMatch(final CSNodeWrapper parent, final CSNodeWrapper entityParent) { if (parent != null && entityParent != null) { if (parent.getId() != null && parent.getId().equals(entityParent.getId())) { return true; } else if (parent.getId() == null && entityParent.getId() == null && parent == entityParent) { return true; } else { return false; } } else if (parent == null && entityParent == null) { return true; } else { return false; } }
[ "protected", "boolean", "doesParentMatch", "(", "final", "CSNodeWrapper", "parent", ",", "final", "CSNodeWrapper", "entityParent", ")", "{", "if", "(", "parent", "!=", "null", "&&", "entityParent", "!=", "null", ")", "{", "if", "(", "parent", ".", "getId", "(", ")", "!=", "null", "&&", "parent", ".", "getId", "(", ")", ".", "equals", "(", "entityParent", ".", "getId", "(", ")", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "parent", ".", "getId", "(", ")", "==", "null", "&&", "entityParent", ".", "getId", "(", ")", "==", "null", "&&", "parent", "==", "entityParent", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "if", "(", "parent", "==", "null", "&&", "entityParent", "==", "null", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks to see if two parent nodes match @param parent The current parent being used for processing. @param entityParent The processed entities parent. @return True if the two match, otherwise false.
[ "Checks", "to", "see", "if", "two", "parent", "nodes", "match" ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1570-L1584
153,207
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.mergeMetaData
protected boolean mergeMetaData(final KeyValueNode<?> metaData, final CSNodeWrapper metaDataEntity) { boolean changed = false; // Meta Data Value final Object value = metaData.getValue(); if (metaData instanceof FileList) { if (metaDataEntity.getAdditionalText() != null) { metaDataEntity.setAdditionalText(null); changed = true; } } else { if (metaDataEntity.getAdditionalText() == null || !metaDataEntity.getAdditionalText().equals(value.toString())) { metaDataEntity.setAdditionalText(value.toString()); changed = true; } } // Node Type if (metaDataEntity.getNodeType() != null) { if (value instanceof SpecTopic && !metaDataEntity.getNodeType().equals(CommonConstants.CS_NODE_META_DATA_TOPIC)) { metaDataEntity.setNodeType(CommonConstants.CS_NODE_META_DATA_TOPIC); } else if (!(value instanceof SpecTopic) && !metaDataEntity.getNodeType().equals(CommonConstants.CS_NODE_META_DATA)) { metaDataEntity.setNodeType(CommonConstants.CS_NODE_META_DATA); } } // Set the Topic details if the Meta Data is a Spec Topic if (value instanceof SpecTopic) { if (mergeTopic((SpecTopic) value, metaDataEntity)) { changed = true; } } // Meta Data Title if (metaDataEntity.getTitle() == null || !metaDataEntity.getTitle().equals(metaData.getKey())) { metaDataEntity.setTitle(metaData.getKey()); changed = true; } return changed; }
java
protected boolean mergeMetaData(final KeyValueNode<?> metaData, final CSNodeWrapper metaDataEntity) { boolean changed = false; // Meta Data Value final Object value = metaData.getValue(); if (metaData instanceof FileList) { if (metaDataEntity.getAdditionalText() != null) { metaDataEntity.setAdditionalText(null); changed = true; } } else { if (metaDataEntity.getAdditionalText() == null || !metaDataEntity.getAdditionalText().equals(value.toString())) { metaDataEntity.setAdditionalText(value.toString()); changed = true; } } // Node Type if (metaDataEntity.getNodeType() != null) { if (value instanceof SpecTopic && !metaDataEntity.getNodeType().equals(CommonConstants.CS_NODE_META_DATA_TOPIC)) { metaDataEntity.setNodeType(CommonConstants.CS_NODE_META_DATA_TOPIC); } else if (!(value instanceof SpecTopic) && !metaDataEntity.getNodeType().equals(CommonConstants.CS_NODE_META_DATA)) { metaDataEntity.setNodeType(CommonConstants.CS_NODE_META_DATA); } } // Set the Topic details if the Meta Data is a Spec Topic if (value instanceof SpecTopic) { if (mergeTopic((SpecTopic) value, metaDataEntity)) { changed = true; } } // Meta Data Title if (metaDataEntity.getTitle() == null || !metaDataEntity.getTitle().equals(metaData.getKey())) { metaDataEntity.setTitle(metaData.getKey()); changed = true; } return changed; }
[ "protected", "boolean", "mergeMetaData", "(", "final", "KeyValueNode", "<", "?", ">", "metaData", ",", "final", "CSNodeWrapper", "metaDataEntity", ")", "{", "boolean", "changed", "=", "false", ";", "// Meta Data Value", "final", "Object", "value", "=", "metaData", ".", "getValue", "(", ")", ";", "if", "(", "metaData", "instanceof", "FileList", ")", "{", "if", "(", "metaDataEntity", ".", "getAdditionalText", "(", ")", "!=", "null", ")", "{", "metaDataEntity", ".", "setAdditionalText", "(", "null", ")", ";", "changed", "=", "true", ";", "}", "}", "else", "{", "if", "(", "metaDataEntity", ".", "getAdditionalText", "(", ")", "==", "null", "||", "!", "metaDataEntity", ".", "getAdditionalText", "(", ")", ".", "equals", "(", "value", ".", "toString", "(", ")", ")", ")", "{", "metaDataEntity", ".", "setAdditionalText", "(", "value", ".", "toString", "(", ")", ")", ";", "changed", "=", "true", ";", "}", "}", "// Node Type", "if", "(", "metaDataEntity", ".", "getNodeType", "(", ")", "!=", "null", ")", "{", "if", "(", "value", "instanceof", "SpecTopic", "&&", "!", "metaDataEntity", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_META_DATA_TOPIC", ")", ")", "{", "metaDataEntity", ".", "setNodeType", "(", "CommonConstants", ".", "CS_NODE_META_DATA_TOPIC", ")", ";", "}", "else", "if", "(", "!", "(", "value", "instanceof", "SpecTopic", ")", "&&", "!", "metaDataEntity", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_META_DATA", ")", ")", "{", "metaDataEntity", ".", "setNodeType", "(", "CommonConstants", ".", "CS_NODE_META_DATA", ")", ";", "}", "}", "// Set the Topic details if the Meta Data is a Spec Topic", "if", "(", "value", "instanceof", "SpecTopic", ")", "{", "if", "(", "mergeTopic", "(", "(", "SpecTopic", ")", "value", ",", "metaDataEntity", ")", ")", "{", "changed", "=", "true", ";", "}", "}", "// Meta Data Title", "if", "(", "metaDataEntity", ".", "getTitle", "(", ")", "==", "null", "||", "!", "metaDataEntity", ".", "getTitle", "(", ")", ".", "equals", "(", "metaData", ".", "getKey", "(", ")", ")", ")", "{", "metaDataEntity", ".", "setTitle", "(", "metaData", ".", "getKey", "(", ")", ")", ";", "changed", "=", "true", ";", "}", "return", "changed", ";", "}" ]
Merges a Content Specs meta data with a Content Spec Entities meta data @param metaData The meta data object to be merged into a entity meta data object @param metaDataEntity The meta data entity to merge with. @return True if some value was changed, otherwise false.
[ "Merges", "a", "Content", "Specs", "meta", "data", "with", "a", "Content", "Spec", "Entities", "meta", "data" ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1593-L1633
153,208
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.mergeRelationships
protected void mergeRelationships(final Map<SpecNode, CSNodeWrapper> nodeMapping, final DataProviderFactory providerFactory) { final CSNodeProvider nodeProvider = providerFactory.getProvider(CSNodeProvider.class); for (final Map.Entry<SpecNode, CSNodeWrapper> nodes : nodeMapping.entrySet()) { // Only process relationship nodes if (!(nodes.getKey() instanceof SpecNodeWithRelationships)) continue; // Get the matching node and entity final SpecNodeWithRelationships specNode = (SpecNodeWithRelationships) nodes.getKey(); final CSNodeWrapper entity = nodes.getValue(); // Check if the node or entity have any relationships, if not then the node doesn't need to be merged if (!specNode.getRelationships().isEmpty() || entity.getRelatedToNodes() != null && !entity.getRelatedToNodes().isEmpty()) { // merge the relationships from the spec topic to the entity mergeRelationship(nodeMapping, specNode, entity, nodeProvider); } } }
java
protected void mergeRelationships(final Map<SpecNode, CSNodeWrapper> nodeMapping, final DataProviderFactory providerFactory) { final CSNodeProvider nodeProvider = providerFactory.getProvider(CSNodeProvider.class); for (final Map.Entry<SpecNode, CSNodeWrapper> nodes : nodeMapping.entrySet()) { // Only process relationship nodes if (!(nodes.getKey() instanceof SpecNodeWithRelationships)) continue; // Get the matching node and entity final SpecNodeWithRelationships specNode = (SpecNodeWithRelationships) nodes.getKey(); final CSNodeWrapper entity = nodes.getValue(); // Check if the node or entity have any relationships, if not then the node doesn't need to be merged if (!specNode.getRelationships().isEmpty() || entity.getRelatedToNodes() != null && !entity.getRelatedToNodes().isEmpty()) { // merge the relationships from the spec topic to the entity mergeRelationship(nodeMapping, specNode, entity, nodeProvider); } } }
[ "protected", "void", "mergeRelationships", "(", "final", "Map", "<", "SpecNode", ",", "CSNodeWrapper", ">", "nodeMapping", ",", "final", "DataProviderFactory", "providerFactory", ")", "{", "final", "CSNodeProvider", "nodeProvider", "=", "providerFactory", ".", "getProvider", "(", "CSNodeProvider", ".", "class", ")", ";", "for", "(", "final", "Map", ".", "Entry", "<", "SpecNode", ",", "CSNodeWrapper", ">", "nodes", ":", "nodeMapping", ".", "entrySet", "(", ")", ")", "{", "// Only process relationship nodes", "if", "(", "!", "(", "nodes", ".", "getKey", "(", ")", "instanceof", "SpecNodeWithRelationships", ")", ")", "continue", ";", "// Get the matching node and entity", "final", "SpecNodeWithRelationships", "specNode", "=", "(", "SpecNodeWithRelationships", ")", "nodes", ".", "getKey", "(", ")", ";", "final", "CSNodeWrapper", "entity", "=", "nodes", ".", "getValue", "(", ")", ";", "// Check if the node or entity have any relationships, if not then the node doesn't need to be merged", "if", "(", "!", "specNode", ".", "getRelationships", "(", ")", ".", "isEmpty", "(", ")", "||", "entity", ".", "getRelatedToNodes", "(", ")", "!=", "null", "&&", "!", "entity", ".", "getRelatedToNodes", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "// merge the relationships from the spec topic to the entity", "mergeRelationship", "(", "nodeMapping", ",", "specNode", ",", "entity", ",", "nodeProvider", ")", ";", "}", "}", "}" ]
Merges the relationships for all Spec Topics into their counterpart Entity nodes. @param nodeMapping The mapping of Spec Nodes to Entity nodes. @param providerFactory
[ "Merges", "the", "relationships", "for", "all", "Spec", "Topics", "into", "their", "counterpart", "Entity", "nodes", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1838-L1855
153,209
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.findExistingRelatedNode
protected CSRelatedNodeWrapper findExistingRelatedNode(final Relationship relationship, final List<CSRelatedNodeWrapper> topicRelatedNodes) { if (topicRelatedNodes != null) { // Loop over the current nodes and see if any match for (final CSRelatedNodeWrapper relatedNode : topicRelatedNodes) { if (relationship instanceof TargetRelationship) { if (doesRelationshipMatch((TargetRelationship) relationship, relatedNode)) { return relatedNode; } } else { if (doesRelationshipMatch((TopicRelationship) relationship, relatedNode)) { return relatedNode; } } } } return null; }
java
protected CSRelatedNodeWrapper findExistingRelatedNode(final Relationship relationship, final List<CSRelatedNodeWrapper> topicRelatedNodes) { if (topicRelatedNodes != null) { // Loop over the current nodes and see if any match for (final CSRelatedNodeWrapper relatedNode : topicRelatedNodes) { if (relationship instanceof TargetRelationship) { if (doesRelationshipMatch((TargetRelationship) relationship, relatedNode)) { return relatedNode; } } else { if (doesRelationshipMatch((TopicRelationship) relationship, relatedNode)) { return relatedNode; } } } } return null; }
[ "protected", "CSRelatedNodeWrapper", "findExistingRelatedNode", "(", "final", "Relationship", "relationship", ",", "final", "List", "<", "CSRelatedNodeWrapper", ">", "topicRelatedNodes", ")", "{", "if", "(", "topicRelatedNodes", "!=", "null", ")", "{", "// Loop over the current nodes and see if any match", "for", "(", "final", "CSRelatedNodeWrapper", "relatedNode", ":", "topicRelatedNodes", ")", "{", "if", "(", "relationship", "instanceof", "TargetRelationship", ")", "{", "if", "(", "doesRelationshipMatch", "(", "(", "TargetRelationship", ")", "relationship", ",", "relatedNode", ")", ")", "{", "return", "relatedNode", ";", "}", "}", "else", "{", "if", "(", "doesRelationshipMatch", "(", "(", "TopicRelationship", ")", "relationship", ",", "relatedNode", ")", ")", "{", "return", "relatedNode", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Finds an existing relationship for a topic. @param relationship The relationship to be found. @param topicRelatedNodes The topic related nodes to find the relationship from. @return The related Entity, otherwise null if one can't be found.
[ "Finds", "an", "existing", "relationship", "for", "a", "topic", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L1982-L2000
153,210
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.getTransformableNodes
protected List<Node> getTransformableNodes(final List<Node> childNodes) { final List<Node> nodes = new LinkedList<Node>(); for (final Node childNode : childNodes) { if (isTransformableNode(childNode)) { nodes.add(childNode); } } return nodes; }
java
protected List<Node> getTransformableNodes(final List<Node> childNodes) { final List<Node> nodes = new LinkedList<Node>(); for (final Node childNode : childNodes) { if (isTransformableNode(childNode)) { nodes.add(childNode); } } return nodes; }
[ "protected", "List", "<", "Node", ">", "getTransformableNodes", "(", "final", "List", "<", "Node", ">", "childNodes", ")", "{", "final", "List", "<", "Node", ">", "nodes", "=", "new", "LinkedList", "<", "Node", ">", "(", ")", ";", "for", "(", "final", "Node", "childNode", ":", "childNodes", ")", "{", "if", "(", "isTransformableNode", "(", "childNode", ")", ")", "{", "nodes", ".", "add", "(", "childNode", ")", ";", "}", "}", "return", "nodes", ";", "}" ]
Gets a list of child nodes that can be transformed. @param childNodes The list of nodes to filter for translatable nodes. @return A list of transformable nodes.
[ "Gets", "a", "list", "of", "child", "nodes", "that", "can", "be", "transformed", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2008-L2017
153,211
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.isTransformableNode
protected boolean isTransformableNode(final Node childNode) { if (childNode instanceof KeyValueNode) { return !IGNORE_META_DATA.contains(((KeyValueNode) childNode).getKey()); } else { return childNode instanceof SpecNode || childNode instanceof Comment || childNode instanceof Level || childNode instanceof File; } }
java
protected boolean isTransformableNode(final Node childNode) { if (childNode instanceof KeyValueNode) { return !IGNORE_META_DATA.contains(((KeyValueNode) childNode).getKey()); } else { return childNode instanceof SpecNode || childNode instanceof Comment || childNode instanceof Level || childNode instanceof File; } }
[ "protected", "boolean", "isTransformableNode", "(", "final", "Node", "childNode", ")", "{", "if", "(", "childNode", "instanceof", "KeyValueNode", ")", "{", "return", "!", "IGNORE_META_DATA", ".", "contains", "(", "(", "(", "KeyValueNode", ")", "childNode", ")", ".", "getKey", "(", ")", ")", ";", "}", "else", "{", "return", "childNode", "instanceof", "SpecNode", "||", "childNode", "instanceof", "Comment", "||", "childNode", "instanceof", "Level", "||", "childNode", "instanceof", "File", ";", "}", "}" ]
Checks to see if a node is a node that can be transformed and saved, @param childNode The node to be checked. @return True if the node can be transformed, otherwise false.
[ "Checks", "to", "see", "if", "a", "node", "is", "a", "node", "that", "can", "be", "transformed", "and", "saved" ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2025-L2031
153,212
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesMetaDataMatch
protected boolean doesMetaDataMatch(final KeyValueNode<?> metaData, final CSNodeWrapper node) { if (!(node.getNodeType().equals(CommonConstants.CS_NODE_META_DATA) || node.getNodeType().equals( CommonConstants.CS_NODE_META_DATA_TOPIC))) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (metaData.getUniqueId() != null && metaData.getUniqueId().matches("^\\d.*")) { return metaData.getUniqueId().equals(Integer.toString(node.getId())); } else { // Allow for old abstract references. if (metaData.getKey().equals(CommonConstants.CS_ABSTRACT_TITLE) && node.getTitle().equals( CommonConstants.CS_ABSTRACT_ALTERNATE_TITLE)) { return true; } // Allow for alternate file references. if (metaData.getKey().equals(CommonConstants.CS_FILE_TITLE) && node.getTitle().equals(CommonConstants.CS_FILE_SHORT_TITLE)) { return true; } // Check if the key matches, if it does than the nodes match. return metaData.getKey().equals(node.getTitle()); } }
java
protected boolean doesMetaDataMatch(final KeyValueNode<?> metaData, final CSNodeWrapper node) { if (!(node.getNodeType().equals(CommonConstants.CS_NODE_META_DATA) || node.getNodeType().equals( CommonConstants.CS_NODE_META_DATA_TOPIC))) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (metaData.getUniqueId() != null && metaData.getUniqueId().matches("^\\d.*")) { return metaData.getUniqueId().equals(Integer.toString(node.getId())); } else { // Allow for old abstract references. if (metaData.getKey().equals(CommonConstants.CS_ABSTRACT_TITLE) && node.getTitle().equals( CommonConstants.CS_ABSTRACT_ALTERNATE_TITLE)) { return true; } // Allow for alternate file references. if (metaData.getKey().equals(CommonConstants.CS_FILE_TITLE) && node.getTitle().equals(CommonConstants.CS_FILE_SHORT_TITLE)) { return true; } // Check if the key matches, if it does than the nodes match. return metaData.getKey().equals(node.getTitle()); } }
[ "protected", "boolean", "doesMetaDataMatch", "(", "final", "KeyValueNode", "<", "?", ">", "metaData", ",", "final", "CSNodeWrapper", "node", ")", "{", "if", "(", "!", "(", "node", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_META_DATA", ")", "||", "node", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_META_DATA_TOPIC", ")", ")", ")", "return", "false", ";", "// If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare", "if", "(", "metaData", ".", "getUniqueId", "(", ")", "!=", "null", "&&", "metaData", ".", "getUniqueId", "(", ")", ".", "matches", "(", "\"^\\\\d.*\"", ")", ")", "{", "return", "metaData", ".", "getUniqueId", "(", ")", ".", "equals", "(", "Integer", ".", "toString", "(", "node", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "{", "// Allow for old abstract references.", "if", "(", "metaData", ".", "getKey", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_ABSTRACT_TITLE", ")", "&&", "node", ".", "getTitle", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_ABSTRACT_ALTERNATE_TITLE", ")", ")", "{", "return", "true", ";", "}", "// Allow for alternate file references.", "if", "(", "metaData", ".", "getKey", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_FILE_TITLE", ")", "&&", "node", ".", "getTitle", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_FILE_SHORT_TITLE", ")", ")", "{", "return", "true", ";", "}", "// Check if the key matches, if it does than the nodes match.", "return", "metaData", ".", "getKey", "(", ")", ".", "equals", "(", "node", ".", "getTitle", "(", ")", ")", ";", "}", "}" ]
Checks to see if a ContentSpec meta data matches a Content Spec Entity meta data. @param metaData The ContentSpec meta data object. @param node The Content Spec Entity topic. @return True if the meta data is determined to match otherwise false.
[ "Checks", "to", "see", "if", "a", "ContentSpec", "meta", "data", "matches", "a", "Content", "Spec", "Entity", "meta", "data", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2040-L2062
153,213
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesLevelMatch
protected boolean doesLevelMatch(final Level level, final CSNodeWrapper node, boolean matchContent) { if (!EntityUtilities.isNodeALevel(node)) return false; // If the unique id is not from the parser, than use the unique id to compare if (level.getUniqueId() != null && level.getUniqueId().matches("^\\d.*")) { return level.getUniqueId().equals(Integer.toString(node.getId())); } else { // If the target ids match then the level should be the same if (level.getTargetId() != null && level.getTargetId() == node.getTargetId()) { return true; } if (matchContent) { // Make sure the level type matches if (node.getNodeType() != level.getLevelType().getId()) return false; return level.getTitle().equals(node.getTitle()); } else { return StringUtilities.similarDamerauLevenshtein(level.getTitle(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } } }
java
protected boolean doesLevelMatch(final Level level, final CSNodeWrapper node, boolean matchContent) { if (!EntityUtilities.isNodeALevel(node)) return false; // If the unique id is not from the parser, than use the unique id to compare if (level.getUniqueId() != null && level.getUniqueId().matches("^\\d.*")) { return level.getUniqueId().equals(Integer.toString(node.getId())); } else { // If the target ids match then the level should be the same if (level.getTargetId() != null && level.getTargetId() == node.getTargetId()) { return true; } if (matchContent) { // Make sure the level type matches if (node.getNodeType() != level.getLevelType().getId()) return false; return level.getTitle().equals(node.getTitle()); } else { return StringUtilities.similarDamerauLevenshtein(level.getTitle(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } } }
[ "protected", "boolean", "doesLevelMatch", "(", "final", "Level", "level", ",", "final", "CSNodeWrapper", "node", ",", "boolean", "matchContent", ")", "{", "if", "(", "!", "EntityUtilities", ".", "isNodeALevel", "(", "node", ")", ")", "return", "false", ";", "// If the unique id is not from the parser, than use the unique id to compare", "if", "(", "level", ".", "getUniqueId", "(", ")", "!=", "null", "&&", "level", ".", "getUniqueId", "(", ")", ".", "matches", "(", "\"^\\\\d.*\"", ")", ")", "{", "return", "level", ".", "getUniqueId", "(", ")", ".", "equals", "(", "Integer", ".", "toString", "(", "node", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "{", "// If the target ids match then the level should be the same", "if", "(", "level", ".", "getTargetId", "(", ")", "!=", "null", "&&", "level", ".", "getTargetId", "(", ")", "==", "node", ".", "getTargetId", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "matchContent", ")", "{", "// Make sure the level type matches", "if", "(", "node", ".", "getNodeType", "(", ")", "!=", "level", ".", "getLevelType", "(", ")", ".", "getId", "(", ")", ")", "return", "false", ";", "return", "level", ".", "getTitle", "(", ")", ".", "equals", "(", "node", ".", "getTitle", "(", ")", ")", ";", "}", "else", "{", "return", "StringUtilities", ".", "similarDamerauLevenshtein", "(", "level", ".", "getTitle", "(", ")", ",", "node", ".", "getTitle", "(", ")", ")", ">=", "ProcessorConstants", ".", "MIN_MATCH_SIMILARITY", ";", "}", "}", "}" ]
Checks to see if a ContentSpec level matches a Content Spec Entity level. @param level The ContentSpec level object. @param node The Content Spec Entity level. @param matchContent If the level title has to match exactly, otherwise it should match to a reasonable extent. @return True if the level is determined to match otherwise false.
[ "Checks", "to", "see", "if", "a", "ContentSpec", "level", "matches", "a", "Content", "Spec", "Entity", "level", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2072-L2094
153,214
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesFileMatch
protected boolean doesFileMatch(final File file, final CSNodeWrapper node) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_FILE)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (file.getUniqueId() != null && file.getUniqueId().matches("^\\d.*")) { return file.getUniqueId().equals(Integer.toString(node.getId())); } else { // Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match return file.getId().equals(node.getEntityId()); } }
java
protected boolean doesFileMatch(final File file, final CSNodeWrapper node) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_FILE)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (file.getUniqueId() != null && file.getUniqueId().matches("^\\d.*")) { return file.getUniqueId().equals(Integer.toString(node.getId())); } else { // Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match return file.getId().equals(node.getEntityId()); } }
[ "protected", "boolean", "doesFileMatch", "(", "final", "File", "file", ",", "final", "CSNodeWrapper", "node", ")", "{", "if", "(", "!", "node", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_FILE", ")", ")", "return", "false", ";", "// If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare", "if", "(", "file", ".", "getUniqueId", "(", ")", "!=", "null", "&&", "file", ".", "getUniqueId", "(", ")", ".", "matches", "(", "\"^\\\\d.*\"", ")", ")", "{", "return", "file", ".", "getUniqueId", "(", ")", ".", "equals", "(", "Integer", ".", "toString", "(", "node", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "{", "// Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match", "return", "file", ".", "getId", "(", ")", ".", "equals", "(", "node", ".", "getEntityId", "(", ")", ")", ";", "}", "}" ]
Checks to see if a ContentSpec topic matches a Content Spec Entity file. @param file The ContentSpec file object. @param node The Content Spec Entity file. @return True if the file is determined to match otherwise false.
[ "Checks", "to", "see", "if", "a", "ContentSpec", "topic", "matches", "a", "Content", "Spec", "Entity", "file", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2174-L2184
153,215
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesCommentMatch
protected boolean doesCommentMatch(final Comment comment, final CSNodeWrapper node, boolean matchContent) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_COMMENT)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (comment.getUniqueId() != null && comment.getUniqueId().matches("^\\d.*")) { return comment.getUniqueId().equals(Integer.toString(node.getId())); } else if (matchContent) { return StringUtilities.similarDamerauLevenshtein(comment.getText(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } else { // Check the parent has the same name if (comment.getParent() != null) { if (comment.getParent() instanceof ContentSpec) { return node.getParent() == null; } else if (comment.getParent() instanceof Level && node.getParent() != null) { final Level parent = ((Level) comment.getParent()); return parent.getTitle().equals(node.getParent().getTitle()); } else { return false; } } return true; } }
java
protected boolean doesCommentMatch(final Comment comment, final CSNodeWrapper node, boolean matchContent) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_COMMENT)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (comment.getUniqueId() != null && comment.getUniqueId().matches("^\\d.*")) { return comment.getUniqueId().equals(Integer.toString(node.getId())); } else if (matchContent) { return StringUtilities.similarDamerauLevenshtein(comment.getText(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } else { // Check the parent has the same name if (comment.getParent() != null) { if (comment.getParent() instanceof ContentSpec) { return node.getParent() == null; } else if (comment.getParent() instanceof Level && node.getParent() != null) { final Level parent = ((Level) comment.getParent()); return parent.getTitle().equals(node.getParent().getTitle()); } else { return false; } } return true; } }
[ "protected", "boolean", "doesCommentMatch", "(", "final", "Comment", "comment", ",", "final", "CSNodeWrapper", "node", ",", "boolean", "matchContent", ")", "{", "if", "(", "!", "node", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_COMMENT", ")", ")", "return", "false", ";", "// If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare", "if", "(", "comment", ".", "getUniqueId", "(", ")", "!=", "null", "&&", "comment", ".", "getUniqueId", "(", ")", ".", "matches", "(", "\"^\\\\d.*\"", ")", ")", "{", "return", "comment", ".", "getUniqueId", "(", ")", ".", "equals", "(", "Integer", ".", "toString", "(", "node", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "matchContent", ")", "{", "return", "StringUtilities", ".", "similarDamerauLevenshtein", "(", "comment", ".", "getText", "(", ")", ",", "node", ".", "getTitle", "(", ")", ")", ">=", "ProcessorConstants", ".", "MIN_MATCH_SIMILARITY", ";", "}", "else", "{", "// Check the parent has the same name", "if", "(", "comment", ".", "getParent", "(", ")", "!=", "null", ")", "{", "if", "(", "comment", ".", "getParent", "(", ")", "instanceof", "ContentSpec", ")", "{", "return", "node", ".", "getParent", "(", ")", "==", "null", ";", "}", "else", "if", "(", "comment", ".", "getParent", "(", ")", "instanceof", "Level", "&&", "node", ".", "getParent", "(", ")", "!=", "null", ")", "{", "final", "Level", "parent", "=", "(", "(", "Level", ")", "comment", ".", "getParent", "(", ")", ")", ";", "return", "parent", ".", "getTitle", "(", ")", ".", "equals", "(", "node", ".", "getParent", "(", ")", ".", "getTitle", "(", ")", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "}" ]
Checks to see if a ContentSpec comment matches a Content Spec Entity comment. @param comment The ContentSpec comment object. @param node The Content Spec Entity comment. @param matchContent If the contents of the comment have to match to a reasonable extent. @return True if the comment is determined to match otherwise false.
[ "Checks", "to", "see", "if", "a", "ContentSpec", "comment", "matches", "a", "Content", "Spec", "Entity", "comment", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2247-L2270
153,216
pressgang-ccms/PressGangCCMSContentSpecProcessor
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java
ContentSpecProcessor.doesCommonContentMatch
protected boolean doesCommonContentMatch(final CommonContent commonContent, final CSNodeWrapper node, boolean matchContent) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_COMMON_CONTENT)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (commonContent.getUniqueId() != null && commonContent.getUniqueId().matches("^\\d.*")) { return commonContent.getUniqueId().equals(Integer.toString(node.getId())); } else if (matchContent) { return StringUtilities.similarDamerauLevenshtein(commonContent.getTitle(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } else { // Check the parent has the same name if (commonContent.getParent() != null) { return commonContent.getParent().getTitle().equals(node.getParent().getTitle()); } return true; } }
java
protected boolean doesCommonContentMatch(final CommonContent commonContent, final CSNodeWrapper node, boolean matchContent) { if (!node.getNodeType().equals(CommonConstants.CS_NODE_COMMON_CONTENT)) return false; // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare if (commonContent.getUniqueId() != null && commonContent.getUniqueId().matches("^\\d.*")) { return commonContent.getUniqueId().equals(Integer.toString(node.getId())); } else if (matchContent) { return StringUtilities.similarDamerauLevenshtein(commonContent.getTitle(), node.getTitle()) >= ProcessorConstants.MIN_MATCH_SIMILARITY; } else { // Check the parent has the same name if (commonContent.getParent() != null) { return commonContent.getParent().getTitle().equals(node.getParent().getTitle()); } return true; } }
[ "protected", "boolean", "doesCommonContentMatch", "(", "final", "CommonContent", "commonContent", ",", "final", "CSNodeWrapper", "node", ",", "boolean", "matchContent", ")", "{", "if", "(", "!", "node", ".", "getNodeType", "(", ")", ".", "equals", "(", "CommonConstants", ".", "CS_NODE_COMMON_CONTENT", ")", ")", "return", "false", ";", "// If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare", "if", "(", "commonContent", ".", "getUniqueId", "(", ")", "!=", "null", "&&", "commonContent", ".", "getUniqueId", "(", ")", ".", "matches", "(", "\"^\\\\d.*\"", ")", ")", "{", "return", "commonContent", ".", "getUniqueId", "(", ")", ".", "equals", "(", "Integer", ".", "toString", "(", "node", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "matchContent", ")", "{", "return", "StringUtilities", ".", "similarDamerauLevenshtein", "(", "commonContent", ".", "getTitle", "(", ")", ",", "node", ".", "getTitle", "(", ")", ")", ">=", "ProcessorConstants", ".", "MIN_MATCH_SIMILARITY", ";", "}", "else", "{", "// Check the parent has the same name", "if", "(", "commonContent", ".", "getParent", "(", ")", "!=", "null", ")", "{", "return", "commonContent", ".", "getParent", "(", ")", ".", "getTitle", "(", ")", ".", "equals", "(", "node", ".", "getParent", "(", ")", ".", "getTitle", "(", ")", ")", ";", "}", "return", "true", ";", "}", "}" ]
Checks to see if a ContentSpec Common Content matches a Content Spec Entity Common Content. @param commonContent The ContentSpec common content object. @param node The Content Spec Entity common content. @param matchContent If the contents of the common content have to match to a reasonable extent. @return True if the common content is determined to match otherwise false.
[ "Checks", "to", "see", "if", "a", "ContentSpec", "Common", "Content", "matches", "a", "Content", "Spec", "Entity", "Common", "Content", "." ]
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecProcessor.java#L2280-L2297
153,217
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.schedule
public ScheduledFuture<?> schedule(Runnable command, TemporalAccessor time) { ensureWaiterRunning(); log(logLevel, "schedule(%s, %s)", command, time); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(command, Instant.from(time), null, false); delayQueue.add(future); return future; }
java
public ScheduledFuture<?> schedule(Runnable command, TemporalAccessor time) { ensureWaiterRunning(); log(logLevel, "schedule(%s, %s)", command, time); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(command, Instant.from(time), null, false); delayQueue.add(future); return future; }
[ "public", "ScheduledFuture", "<", "?", ">", "schedule", "(", "Runnable", "command", ",", "TemporalAccessor", "time", ")", "{", "ensureWaiterRunning", "(", ")", ";", "log", "(", "logLevel", ",", "\"schedule(%s, %s)\"", ",", "command", ",", "time", ")", ";", "RunnableScheduledFutureImpl", "future", "=", "new", "RunnableScheduledFutureImpl", "(", "command", ",", "Instant", ".", "from", "(", "time", ")", ",", "null", ",", "false", ")", ";", "delayQueue", ".", "add", "(", "future", ")", ";", "return", "future", ";", "}" ]
Schedule command to be run not earlier than time. @param command @param time Temporal that supports INSTANT_SECONDS and NANO_OF_SECOND. @return
[ "Schedule", "command", "to", "be", "run", "not", "earlier", "than", "time", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L109-L116
153,218
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.schedule
public <V> ScheduledFuture<V> schedule(Callable<V> callable, TemporalAccessor time) { ensureWaiterRunning(); log(logLevel, "schedule(%s, %s)", callable, time); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(callable, Instant.from(time), null, false); delayQueue.add(future); return future; }
java
public <V> ScheduledFuture<V> schedule(Callable<V> callable, TemporalAccessor time) { ensureWaiterRunning(); log(logLevel, "schedule(%s, %s)", callable, time); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(callable, Instant.from(time), null, false); delayQueue.add(future); return future; }
[ "public", "<", "V", ">", "ScheduledFuture", "<", "V", ">", "schedule", "(", "Callable", "<", "V", ">", "callable", ",", "TemporalAccessor", "time", ")", "{", "ensureWaiterRunning", "(", ")", ";", "log", "(", "logLevel", ",", "\"schedule(%s, %s)\"", ",", "callable", ",", "time", ")", ";", "RunnableScheduledFutureImpl", "future", "=", "new", "RunnableScheduledFutureImpl", "(", "callable", ",", "Instant", ".", "from", "(", "time", ")", ",", "null", ",", "false", ")", ";", "delayQueue", ".", "add", "(", "future", ")", ";", "return", "future", ";", "}" ]
Schedule callable to be run not earlier than time. @param <V> @param callable @param time TemporalAccessor that supports INSTANT_SECONDS and NANO_OF_SECOND. @return
[ "Schedule", "callable", "to", "be", "run", "not", "earlier", "than", "time", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L124-L131
153,219
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.iterateAtFixedRate
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Runnable... commands) { return iterateAtFixedRate(initialDelay, period, unit, new ArrayIterator<>(commands)); }
java
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Runnable... commands) { return iterateAtFixedRate(initialDelay, period, unit, new ArrayIterator<>(commands)); }
[ "public", "ScheduledFuture", "<", "?", ">", "iterateAtFixedRate", "(", "long", "initialDelay", ",", "long", "period", ",", "TimeUnit", "unit", ",", "Runnable", "...", "commands", ")", "{", "return", "iterateAtFixedRate", "(", "initialDelay", ",", "period", ",", "unit", ",", "new", "ArrayIterator", "<>", "(", "commands", ")", ")", ";", "}" ]
After initialDelay executes commands with period delay or command throws exception. @param initialDelay @param period @param unit @param commands @return @see java.util.concurrent.ScheduledThreadPoolExecutor#scheduleAtFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)
[ "After", "initialDelay", "executes", "commands", "with", "period", "delay", "or", "command", "throws", "exception", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L180-L183
153,220
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.iterateAtFixedRate
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Collection<Runnable> commands) { return iterateAtFixedRate(initialDelay, period, unit, commands.iterator()); }
java
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Collection<Runnable> commands) { return iterateAtFixedRate(initialDelay, period, unit, commands.iterator()); }
[ "public", "ScheduledFuture", "<", "?", ">", "iterateAtFixedRate", "(", "long", "initialDelay", ",", "long", "period", ",", "TimeUnit", "unit", ",", "Collection", "<", "Runnable", ">", "commands", ")", "{", "return", "iterateAtFixedRate", "(", "initialDelay", ",", "period", ",", "unit", ",", "commands", ".", "iterator", "(", ")", ")", ";", "}" ]
After initialDelay executes commands using collections iterator until either iterator has no more commands or command throws exception. @param initialDelay @param period @param unit @param commands @return @see java.util.concurrent.ScheduledThreadPoolExecutor#scheduleAtFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)
[ "After", "initialDelay", "executes", "commands", "using", "collections", "iterator", "until", "either", "iterator", "has", "no", "more", "commands", "or", "command", "throws", "exception", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L206-L209
153,221
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.iterateAtFixedRate
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Iterator<Runnable> commands) { ensureWaiterRunning(); log(logLevel, "iterateAtFixedRate(%d, %d, %s)", initialDelay, period, unit); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(new RunnableIterator(commands), initialDelay, period, unit, false); delayQueue.add(future); return future; }
java
public ScheduledFuture<?> iterateAtFixedRate(long initialDelay, long period, TimeUnit unit, Iterator<Runnable> commands) { ensureWaiterRunning(); log(logLevel, "iterateAtFixedRate(%d, %d, %s)", initialDelay, period, unit); RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(new RunnableIterator(commands), initialDelay, period, unit, false); delayQueue.add(future); return future; }
[ "public", "ScheduledFuture", "<", "?", ">", "iterateAtFixedRate", "(", "long", "initialDelay", ",", "long", "period", ",", "TimeUnit", "unit", ",", "Iterator", "<", "Runnable", ">", "commands", ")", "{", "ensureWaiterRunning", "(", ")", ";", "log", "(", "logLevel", ",", "\"iterateAtFixedRate(%d, %d, %s)\"", ",", "initialDelay", ",", "period", ",", "unit", ")", ";", "RunnableScheduledFutureImpl", "future", "=", "new", "RunnableScheduledFutureImpl", "(", "new", "RunnableIterator", "(", "commands", ")", ",", "initialDelay", ",", "period", ",", "unit", ",", "false", ")", ";", "delayQueue", ".", "add", "(", "future", ")", ";", "return", "future", ";", "}" ]
After initialDelay executes commands from iterator until either iterator has no more or command throws exception. @param initialDelay @param period @param unit @param commands @return @see java.util.concurrent.ScheduledThreadPoolExecutor#scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)
[ "After", "initialDelay", "executes", "commands", "from", "iterator", "until", "either", "iterator", "has", "no", "more", "or", "command", "throws", "exception", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L232-L239
153,222
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.concat
public Runnable concat(Runnable... runnables) { if (runnables.length == 0) { throw new IllegalArgumentException("empty"); } Runnable r = runnables[runnables.length-1]; for (int ii=runnables.length-2;ii>=0;ii--) { r = concat(runnables[ii], r); } return r; }
java
public Runnable concat(Runnable... runnables) { if (runnables.length == 0) { throw new IllegalArgumentException("empty"); } Runnable r = runnables[runnables.length-1]; for (int ii=runnables.length-2;ii>=0;ii--) { r = concat(runnables[ii], r); } return r; }
[ "public", "Runnable", "concat", "(", "Runnable", "...", "runnables", ")", "{", "if", "(", "runnables", ".", "length", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"empty\"", ")", ";", "}", "Runnable", "r", "=", "runnables", "[", "runnables", ".", "length", "-", "1", "]", ";", "for", "(", "int", "ii", "=", "runnables", ".", "length", "-", "2", ";", "ii", ">=", "0", ";", "ii", "--", ")", "{", "r", "=", "concat", "(", "runnables", "[", "ii", "]", ",", "r", ")", ";", "}", "return", "r", ";", "}" ]
Concatenates tasks to one task. After first tasks run is completed, next start is submitted and so on, until all tasks are run or exception is thrown. run is completed. @param runnables @return
[ "Concatenates", "tasks", "to", "one", "task", ".", "After", "first", "tasks", "run", "is", "completed", "next", "start", "is", "submitted", "and", "so", "on", "until", "all", "tasks", "are", "run", "or", "exception", "is", "thrown", ".", "run", "is", "completed", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L312-L324
153,223
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.submitAfter
public <V> Future<V> submitAfter(Waiter waiter, Callable<V> callable, long timeout, TimeUnit unit) { AfterTask<V> task = new AfterTask<>(waiter, callable, timeout, unit); log(logLevel, "submit after task %s", task); return (Future<V>) submit(task); }
java
public <V> Future<V> submitAfter(Waiter waiter, Callable<V> callable, long timeout, TimeUnit unit) { AfterTask<V> task = new AfterTask<>(waiter, callable, timeout, unit); log(logLevel, "submit after task %s", task); return (Future<V>) submit(task); }
[ "public", "<", "V", ">", "Future", "<", "V", ">", "submitAfter", "(", "Waiter", "waiter", ",", "Callable", "<", "V", ">", "callable", ",", "long", "timeout", ",", "TimeUnit", "unit", ")", "{", "AfterTask", "<", "V", ">", "task", "=", "new", "AfterTask", "<>", "(", "waiter", ",", "callable", ",", "timeout", ",", "unit", ")", ";", "log", "(", "logLevel", ",", "\"submit after task %s\"", ",", "task", ")", ";", "return", "(", "Future", "<", "V", ">", ")", "submit", "(", "task", ")", ";", "}" ]
submits callable after waiting future to complete or timeout to exceed. If timeout exceeds task is cancelled. @param <V> @param waiter @param callable @param timeout @param unit @return
[ "submits", "callable", "after", "waiting", "future", "to", "complete", "or", "timeout", "to", "exceed", ".", "If", "timeout", "exceeds", "task", "is", "cancelled", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L339-L344
153,224
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java
CachedScheduledThreadPool.submitAfter
public Future<?> submitAfter(Waiter waiter, Runnable runnable, long timeout, TimeUnit unit) { AfterTask<?> task = new AfterTask<>(waiter, runnable, timeout, unit); log(logLevel, "submit after task %s", task); return submit(task); }
java
public Future<?> submitAfter(Waiter waiter, Runnable runnable, long timeout, TimeUnit unit) { AfterTask<?> task = new AfterTask<>(waiter, runnable, timeout, unit); log(logLevel, "submit after task %s", task); return submit(task); }
[ "public", "Future", "<", "?", ">", "submitAfter", "(", "Waiter", "waiter", ",", "Runnable", "runnable", ",", "long", "timeout", ",", "TimeUnit", "unit", ")", "{", "AfterTask", "<", "?", ">", "task", "=", "new", "AfterTask", "<>", "(", "waiter", ",", "runnable", ",", "timeout", ",", "unit", ")", ";", "log", "(", "logLevel", ",", "\"submit after task %s\"", ",", "task", ")", ";", "return", "submit", "(", "task", ")", ";", "}" ]
submits runnable after waiting future to complete or timeout to exceed. If timeout exceeds task is cancelled. @param waiter @param runnable @param timeout @param unit @return
[ "submits", "runnable", "after", "waiting", "future", "to", "complete", "or", "timeout", "to", "exceed", ".", "If", "timeout", "exceeds", "task", "is", "cancelled", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/CachedScheduledThreadPool.java#L354-L359
153,225
inkstand-io/scribble
scribble-pdf/src/main/java/io/inkstand/scribble/pdf/BasePDFMatcher.java
BasePDFMatcher.matches
protected boolean matches(PDF pdf) { try (InputStream inStream = pdf.openStream()) { final PDDocument doc = PDDocument.load(inStream); return matchesPDF(doc); } catch (IOException e) { LOG.debug("Could not load PDF document", e); return false; } }
java
protected boolean matches(PDF pdf) { try (InputStream inStream = pdf.openStream()) { final PDDocument doc = PDDocument.load(inStream); return matchesPDF(doc); } catch (IOException e) { LOG.debug("Could not load PDF document", e); return false; } }
[ "protected", "boolean", "matches", "(", "PDF", "pdf", ")", "{", "try", "(", "InputStream", "inStream", "=", "pdf", ".", "openStream", "(", ")", ")", "{", "final", "PDDocument", "doc", "=", "PDDocument", ".", "load", "(", "inStream", ")", ";", "return", "matchesPDF", "(", "doc", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOG", ".", "debug", "(", "\"Could not load PDF document\"", ",", "e", ")", ";", "return", "false", ";", "}", "}" ]
Is invoked by the matches method when the type of the target object is verified. Override this method to add verifications on the raw data instead of a loaded document. @param pdf the handle for the PDF data @return <code>true</code> if the pdf document is a valid PDF document.
[ "Is", "invoked", "by", "the", "matches", "method", "when", "the", "type", "of", "the", "target", "object", "is", "verified", ".", "Override", "this", "method", "to", "add", "verifications", "on", "the", "raw", "data", "instead", "of", "a", "loaded", "document", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-pdf/src/main/java/io/inkstand/scribble/pdf/BasePDFMatcher.java#L54-L62
153,226
jbundle/jbundle
app/program/project/src/main/java/org/jbundle/app/program/project/report/ProjectReportScreen.java
ProjectReportScreen.getCurrentLevelInfo
public Record getCurrentLevelInfo(int iOffsetFromCurrentLevel, Record record) { int dLevel = (int)this.getScreenRecord().getField(ProjectTaskScreenRecord.CURRENT_LEVEL).getValue(); dLevel = dLevel + iOffsetFromCurrentLevel; this.getScreenRecord().getField(ProjectTaskScreenRecord.CURRENT_LEVEL).setValue(dLevel); if (m_rgCurrentLevelInfo.size() >= dLevel) { try { m_rgCurrentLevelInfo.add((Record)record.clone()); m_rgCurrentLevelInfo.elementAt(dLevel).setKeyArea(ProjectTask.PARENT_PROJECT_TASK_ID_KEY); } catch (CloneNotSupportedException ex) { ex.printStackTrace(); } } return m_rgCurrentLevelInfo.elementAt(dLevel); }
java
public Record getCurrentLevelInfo(int iOffsetFromCurrentLevel, Record record) { int dLevel = (int)this.getScreenRecord().getField(ProjectTaskScreenRecord.CURRENT_LEVEL).getValue(); dLevel = dLevel + iOffsetFromCurrentLevel; this.getScreenRecord().getField(ProjectTaskScreenRecord.CURRENT_LEVEL).setValue(dLevel); if (m_rgCurrentLevelInfo.size() >= dLevel) { try { m_rgCurrentLevelInfo.add((Record)record.clone()); m_rgCurrentLevelInfo.elementAt(dLevel).setKeyArea(ProjectTask.PARENT_PROJECT_TASK_ID_KEY); } catch (CloneNotSupportedException ex) { ex.printStackTrace(); } } return m_rgCurrentLevelInfo.elementAt(dLevel); }
[ "public", "Record", "getCurrentLevelInfo", "(", "int", "iOffsetFromCurrentLevel", ",", "Record", "record", ")", "{", "int", "dLevel", "=", "(", "int", ")", "this", ".", "getScreenRecord", "(", ")", ".", "getField", "(", "ProjectTaskScreenRecord", ".", "CURRENT_LEVEL", ")", ".", "getValue", "(", ")", ";", "dLevel", "=", "dLevel", "+", "iOffsetFromCurrentLevel", ";", "this", ".", "getScreenRecord", "(", ")", ".", "getField", "(", "ProjectTaskScreenRecord", ".", "CURRENT_LEVEL", ")", ".", "setValue", "(", "dLevel", ")", ";", "if", "(", "m_rgCurrentLevelInfo", ".", "size", "(", ")", ">=", "dLevel", ")", "{", "try", "{", "m_rgCurrentLevelInfo", ".", "add", "(", "(", "Record", ")", "record", ".", "clone", "(", ")", ")", ";", "m_rgCurrentLevelInfo", ".", "elementAt", "(", "dLevel", ")", ".", "setKeyArea", "(", "ProjectTask", ".", "PARENT_PROJECT_TASK_ID_KEY", ")", ";", "}", "catch", "(", "CloneNotSupportedException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "m_rgCurrentLevelInfo", ".", "elementAt", "(", "dLevel", ")", ";", "}" ]
Add to the current level, then get the record at this level If the record doesn't exist, clone a new one and return it. @param record The main record (that I will clone if I need to) @param iOffsetFromCurrentLevel The amount to bump the level @return The record at this (new) level.
[ "Add", "to", "the", "current", "level", "then", "get", "the", "record", "at", "this", "level", "If", "the", "record", "doesn", "t", "exist", "clone", "a", "new", "one", "and", "return", "it", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/project/src/main/java/org/jbundle/app/program/project/report/ProjectReportScreen.java#L164-L179
153,227
pressgang-ccms/PressGangCCMSRESTv1Common
src/main/java/org/jboss/pressgang/ccms/rest/v1/components/ComponentContentSpecV1.java
ComponentContentSpecV1.fixDisplayedText
public static void fixDisplayedText(final RESTTextContentSpecV1 source) { if (source.getFailedContentSpec() != null) { source.setText(source.getFailedContentSpec()); } }
java
public static void fixDisplayedText(final RESTTextContentSpecV1 source) { if (source.getFailedContentSpec() != null) { source.setText(source.getFailedContentSpec()); } }
[ "public", "static", "void", "fixDisplayedText", "(", "final", "RESTTextContentSpecV1", "source", ")", "{", "if", "(", "source", ".", "getFailedContentSpec", "(", ")", "!=", "null", ")", "{", "source", ".", "setText", "(", "source", ".", "getFailedContentSpec", "(", ")", ")", ";", "}", "}" ]
If the last save of the content spec was not valid, the text field will display the last valid state, the errors field will be populated, and the failedContentSpec will have the invalid spec text. In this situation, the UI will display the invalid spec text. So we copy the invalid text into the text field, and edit as usual. This provides a workflow much like topics where the user can save invalid data, and will receive a warning about it when the save is completed. @param source The spec to fix
[ "If", "the", "last", "save", "of", "the", "content", "spec", "was", "not", "valid", "the", "text", "field", "will", "display", "the", "last", "valid", "state", "the", "errors", "field", "will", "be", "populated", "and", "the", "failedContentSpec", "will", "have", "the", "invalid", "spec", "text", "." ]
0641d21b127297b47035f3b8e55fba81251b419c
https://github.com/pressgang-ccms/PressGangCCMSRESTv1Common/blob/0641d21b127297b47035f3b8e55fba81251b419c/src/main/java/org/jboss/pressgang/ccms/rest/v1/components/ComponentContentSpecV1.java#L68-L72
153,228
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/data/importfix/base/MergeHtml.java
MergeHtml.getSource
public Iterator<Record> getSource() { String strURL = this.getProperty("source"); if (strURL == null) return null; Reader reader = null; try { URL url = new URL(strURL); InputStream inputStream = url.openStream(); InputStreamReader inStream = new InputStreamReader(inputStream); reader = inStream; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Record record = this.getMergeRecord(); SaxHtmlHandler handler = this.getSaxHandler(record); return new HtmlSource(reader, record, handler); }
java
public Iterator<Record> getSource() { String strURL = this.getProperty("source"); if (strURL == null) return null; Reader reader = null; try { URL url = new URL(strURL); InputStream inputStream = url.openStream(); InputStreamReader inStream = new InputStreamReader(inputStream); reader = inStream; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Record record = this.getMergeRecord(); SaxHtmlHandler handler = this.getSaxHandler(record); return new HtmlSource(reader, record, handler); }
[ "public", "Iterator", "<", "Record", ">", "getSource", "(", ")", "{", "String", "strURL", "=", "this", ".", "getProperty", "(", "\"source\"", ")", ";", "if", "(", "strURL", "==", "null", ")", "return", "null", ";", "Reader", "reader", "=", "null", ";", "try", "{", "URL", "url", "=", "new", "URL", "(", "strURL", ")", ";", "InputStream", "inputStream", "=", "url", ".", "openStream", "(", ")", ";", "InputStreamReader", "inStream", "=", "new", "InputStreamReader", "(", "inputStream", ")", ";", "reader", "=", "inStream", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "Record", "record", "=", "this", ".", "getMergeRecord", "(", ")", ";", "SaxHtmlHandler", "handler", "=", "this", ".", "getSaxHandler", "(", "record", ")", ";", "return", "new", "HtmlSource", "(", "reader", ",", "record", ",", "handler", ")", ";", "}" ]
GetSource Method.
[ "GetSource", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/data/importfix/base/MergeHtml.java#L57-L82
153,229
sangupta/jerry-web
src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java
JavascriptMinificationFilter.doFilter
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; String uri = request.getRequestURI(); if(!uri.endsWith(".js")) { filterChain.doFilter(servletRequest, servletResponse); return; } // check if we have this in cache if(CACHE.containsKey(uri)) { ModifiedServletResponse cr = CACHE.get(uri); cr.copyToResponse(servletResponse); return; } // not in cache, obtain fresh response HttpServletResponseWrapperImpl wrapper = new HttpServletResponseWrapperImpl(servletResponse); filterChain.doFilter(servletRequest, wrapper); // flush buffer so that we can read everything wrapper.flushBuffer(); // check for empty response byte[] bytes = wrapper.getBytes(); if(bytes == null || bytes.length == 0) { wrapper.copyToResponse(servletResponse); return; } // check if output is of type text/javascript final String type = wrapper.getContentType(); final String encoding = wrapper.getCharacterEncoding(); LOGGER.info("Content encoding being sent to client: " + encoding); LOGGER.info("Content type being sent to client: " + type); // check if we are JS if(type != null && !isJavascript(type)) { // no JS // output as such wrapper.copyToResponse(servletResponse); return; } // add marker that we processed data wrapper.addHeader("X-Jerry-Minified", "true"); // check if this is gzip-compressed bytes byte[] newBytes = bytes; if(isGZip(bytes)) { newBytes = unGZip(bytes); } // check if we have something here if(newBytes == null) { wrapper.copyToResponse(servletResponse); return; } // go ahead and compress this data String jsCode = null; if (encoding != null) { try { jsCode = new String(newBytes, encoding); } catch (UnsupportedEncodingException e) { LOGGER.error("Unable to encode byte response to string for encoding: " + encoding, e); } } else { jsCode = new String(newBytes); } // compress the code String compressedCode = null; try { compressedCode = compressJavascriptEmbedded(uri, jsCode); } catch(Exception e) { LOGGER.error("Unable to compress Javascript at URL: " + uri, e); wrapper.copyToResponse(servletResponse); return; } if(encoding != null) { bytes = compressedCode.getBytes(encoding); } else { bytes = compressedCode.getBytes(); } // create CACHEABLE RESPONSE ResponseUtils.setCacheHeaders(wrapper, DateUtils.ONE_MONTH); ModifiedServletResponse cr = new ModifiedServletResponse(wrapper, bytes); CACHE.put(uri, cr); // write and move ahead cr.copyToResponse(servletResponse); }
java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; String uri = request.getRequestURI(); if(!uri.endsWith(".js")) { filterChain.doFilter(servletRequest, servletResponse); return; } // check if we have this in cache if(CACHE.containsKey(uri)) { ModifiedServletResponse cr = CACHE.get(uri); cr.copyToResponse(servletResponse); return; } // not in cache, obtain fresh response HttpServletResponseWrapperImpl wrapper = new HttpServletResponseWrapperImpl(servletResponse); filterChain.doFilter(servletRequest, wrapper); // flush buffer so that we can read everything wrapper.flushBuffer(); // check for empty response byte[] bytes = wrapper.getBytes(); if(bytes == null || bytes.length == 0) { wrapper.copyToResponse(servletResponse); return; } // check if output is of type text/javascript final String type = wrapper.getContentType(); final String encoding = wrapper.getCharacterEncoding(); LOGGER.info("Content encoding being sent to client: " + encoding); LOGGER.info("Content type being sent to client: " + type); // check if we are JS if(type != null && !isJavascript(type)) { // no JS // output as such wrapper.copyToResponse(servletResponse); return; } // add marker that we processed data wrapper.addHeader("X-Jerry-Minified", "true"); // check if this is gzip-compressed bytes byte[] newBytes = bytes; if(isGZip(bytes)) { newBytes = unGZip(bytes); } // check if we have something here if(newBytes == null) { wrapper.copyToResponse(servletResponse); return; } // go ahead and compress this data String jsCode = null; if (encoding != null) { try { jsCode = new String(newBytes, encoding); } catch (UnsupportedEncodingException e) { LOGGER.error("Unable to encode byte response to string for encoding: " + encoding, e); } } else { jsCode = new String(newBytes); } // compress the code String compressedCode = null; try { compressedCode = compressJavascriptEmbedded(uri, jsCode); } catch(Exception e) { LOGGER.error("Unable to compress Javascript at URL: " + uri, e); wrapper.copyToResponse(servletResponse); return; } if(encoding != null) { bytes = compressedCode.getBytes(encoding); } else { bytes = compressedCode.getBytes(); } // create CACHEABLE RESPONSE ResponseUtils.setCacheHeaders(wrapper, DateUtils.ONE_MONTH); ModifiedServletResponse cr = new ModifiedServletResponse(wrapper, bytes); CACHE.put(uri, cr); // write and move ahead cr.copyToResponse(servletResponse); }
[ "@", "Override", "public", "void", "doFilter", "(", "ServletRequest", "servletRequest", ",", "ServletResponse", "servletResponse", ",", "FilterChain", "filterChain", ")", "throws", "IOException", ",", "ServletException", "{", "HttpServletRequest", "request", "=", "(", "HttpServletRequest", ")", "servletRequest", ";", "String", "uri", "=", "request", ".", "getRequestURI", "(", ")", ";", "if", "(", "!", "uri", ".", "endsWith", "(", "\".js\"", ")", ")", "{", "filterChain", ".", "doFilter", "(", "servletRequest", ",", "servletResponse", ")", ";", "return", ";", "}", "// check if we have this in cache", "if", "(", "CACHE", ".", "containsKey", "(", "uri", ")", ")", "{", "ModifiedServletResponse", "cr", "=", "CACHE", ".", "get", "(", "uri", ")", ";", "cr", ".", "copyToResponse", "(", "servletResponse", ")", ";", "return", ";", "}", "// not in cache, obtain fresh response", "HttpServletResponseWrapperImpl", "wrapper", "=", "new", "HttpServletResponseWrapperImpl", "(", "servletResponse", ")", ";", "filterChain", ".", "doFilter", "(", "servletRequest", ",", "wrapper", ")", ";", "// flush buffer so that we can read everything", "wrapper", ".", "flushBuffer", "(", ")", ";", "// check for empty response", "byte", "[", "]", "bytes", "=", "wrapper", ".", "getBytes", "(", ")", ";", "if", "(", "bytes", "==", "null", "||", "bytes", ".", "length", "==", "0", ")", "{", "wrapper", ".", "copyToResponse", "(", "servletResponse", ")", ";", "return", ";", "}", "// check if output is of type text/javascript", "final", "String", "type", "=", "wrapper", ".", "getContentType", "(", ")", ";", "final", "String", "encoding", "=", "wrapper", ".", "getCharacterEncoding", "(", ")", ";", "LOGGER", ".", "info", "(", "\"Content encoding being sent to client: \"", "+", "encoding", ")", ";", "LOGGER", ".", "info", "(", "\"Content type being sent to client: \"", "+", "type", ")", ";", "// check if we are JS", "if", "(", "type", "!=", "null", "&&", "!", "isJavascript", "(", "type", ")", ")", "{", "// no JS", "// output as such", "wrapper", ".", "copyToResponse", "(", "servletResponse", ")", ";", "return", ";", "}", "// add marker that we processed data", "wrapper", ".", "addHeader", "(", "\"X-Jerry-Minified\"", ",", "\"true\"", ")", ";", "// check if this is gzip-compressed bytes", "byte", "[", "]", "newBytes", "=", "bytes", ";", "if", "(", "isGZip", "(", "bytes", ")", ")", "{", "newBytes", "=", "unGZip", "(", "bytes", ")", ";", "}", "// check if we have something here", "if", "(", "newBytes", "==", "null", ")", "{", "wrapper", ".", "copyToResponse", "(", "servletResponse", ")", ";", "return", ";", "}", "// go ahead and compress this data", "String", "jsCode", "=", "null", ";", "if", "(", "encoding", "!=", "null", ")", "{", "try", "{", "jsCode", "=", "new", "String", "(", "newBytes", ",", "encoding", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Unable to encode byte response to string for encoding: \"", "+", "encoding", ",", "e", ")", ";", "}", "}", "else", "{", "jsCode", "=", "new", "String", "(", "newBytes", ")", ";", "}", "// compress the code", "String", "compressedCode", "=", "null", ";", "try", "{", "compressedCode", "=", "compressJavascriptEmbedded", "(", "uri", ",", "jsCode", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Unable to compress Javascript at URL: \"", "+", "uri", ",", "e", ")", ";", "wrapper", ".", "copyToResponse", "(", "servletResponse", ")", ";", "return", ";", "}", "if", "(", "encoding", "!=", "null", ")", "{", "bytes", "=", "compressedCode", ".", "getBytes", "(", "encoding", ")", ";", "}", "else", "{", "bytes", "=", "compressedCode", ".", "getBytes", "(", ")", ";", "}", "// create CACHEABLE RESPONSE", "ResponseUtils", ".", "setCacheHeaders", "(", "wrapper", ",", "DateUtils", ".", "ONE_MONTH", ")", ";", "ModifiedServletResponse", "cr", "=", "new", "ModifiedServletResponse", "(", "wrapper", ",", "bytes", ")", ";", "CACHE", ".", "put", "(", "uri", ",", "cr", ")", ";", "// write and move ahead", "cr", ".", "copyToResponse", "(", "servletResponse", ")", ";", "}" ]
Compress JS and CSS files using the Google compiler. @param servletRequest the incoming {@link ServletRequest} instance @param servletResponse the outgoing {@link ServletResponse} instance @param filterChain the {@link FilterChain} being executed @throws IOException if something fails @throws ServletException if something fails @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
[ "Compress", "JS", "and", "CSS", "files", "using", "the", "Google", "compiler", "." ]
f0d02a5d6e7d1c15292509ce588caf52a4ddb895
https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L105-L202
153,230
sangupta/jerry-web
src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java
JavascriptMinificationFilter.isJavascript
private boolean isJavascript(String type) { if("text/javascript".equalsIgnoreCase(type)) { return true; } if("application/x-javascript".equalsIgnoreCase(type)) { return true; } return false; }
java
private boolean isJavascript(String type) { if("text/javascript".equalsIgnoreCase(type)) { return true; } if("application/x-javascript".equalsIgnoreCase(type)) { return true; } return false; }
[ "private", "boolean", "isJavascript", "(", "String", "type", ")", "{", "if", "(", "\"text/javascript\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "return", "true", ";", "}", "if", "(", "\"application/x-javascript\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the resource is javascript or not. @param type @return
[ "Check", "if", "the", "resource", "is", "javascript", "or", "not", "." ]
f0d02a5d6e7d1c15292509ce588caf52a4ddb895
https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L210-L220
153,231
sangupta/jerry-web
src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java
JavascriptMinificationFilter.compressJavascriptEmbedded
private String compressJavascriptEmbedded(final String uri, final String code) { if(code == null || code.isEmpty()) { return code; } int index = uri.lastIndexOf('/'); String name = uri; if(index > 0) { name = uri.substring(index + 1); } List<SourceFile> externs = Collections.emptyList(); List<SourceFile> inputs = Arrays.asList(SourceFile.fromCode(name, code)); CompilerOptions options = new CompilerOptions(); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler(); Result result = compiler.compile(externs, inputs, options); if (result.success) { return compiler.toSource(); } throw new IllegalArgumentException("Unable to compress javascript"); }
java
private String compressJavascriptEmbedded(final String uri, final String code) { if(code == null || code.isEmpty()) { return code; } int index = uri.lastIndexOf('/'); String name = uri; if(index > 0) { name = uri.substring(index + 1); } List<SourceFile> externs = Collections.emptyList(); List<SourceFile> inputs = Arrays.asList(SourceFile.fromCode(name, code)); CompilerOptions options = new CompilerOptions(); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler(); Result result = compiler.compile(externs, inputs, options); if (result.success) { return compiler.toSource(); } throw new IllegalArgumentException("Unable to compress javascript"); }
[ "private", "String", "compressJavascriptEmbedded", "(", "final", "String", "uri", ",", "final", "String", "code", ")", "{", "if", "(", "code", "==", "null", "||", "code", ".", "isEmpty", "(", ")", ")", "{", "return", "code", ";", "}", "int", "index", "=", "uri", ".", "lastIndexOf", "(", "'", "'", ")", ";", "String", "name", "=", "uri", ";", "if", "(", "index", ">", "0", ")", "{", "name", "=", "uri", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "List", "<", "SourceFile", ">", "externs", "=", "Collections", ".", "emptyList", "(", ")", ";", "List", "<", "SourceFile", ">", "inputs", "=", "Arrays", ".", "asList", "(", "SourceFile", ".", "fromCode", "(", "name", ",", "code", ")", ")", ";", "CompilerOptions", "options", "=", "new", "CompilerOptions", "(", ")", ";", "CompilationLevel", ".", "SIMPLE_OPTIMIZATIONS", ".", "setOptionsForCompilationLevel", "(", "options", ")", ";", "com", ".", "google", ".", "javascript", ".", "jscomp", ".", "Compiler", "compiler", "=", "new", "com", ".", "google", ".", "javascript", ".", "jscomp", ".", "Compiler", "(", ")", ";", "Result", "result", "=", "compiler", ".", "compile", "(", "externs", ",", "inputs", ",", "options", ")", ";", "if", "(", "result", ".", "success", ")", "{", "return", "compiler", ".", "toSource", "(", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"Unable to compress javascript\"", ")", ";", "}" ]
Compress the Javascript. @param uri the URI for the JS file @param code the actual Javascript code @return the compressed code for the JS file
[ "Compress", "the", "Javascript", "." ]
f0d02a5d6e7d1c15292509ce588caf52a4ddb895
https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L233-L257
153,232
sangupta/jerry-web
src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java
JavascriptMinificationFilter.unGZip
private byte[] unGZip(byte[] bytes) { if(bytes == null || bytes.length == 0) { return bytes; } GZIPInputStream gzis = null; ByteArrayOutputStream baos = null; try { gzis = new GZIPInputStream(new ByteArrayInputStream(bytes)); baos = new ByteArrayOutputStream(); int len; byte[] buffer = new byte[1024]; while ((len = gzis.read(buffer)) > 0) { baos.write(buffer, 0, len); } return baos.toByteArray(); } catch(IOException e) { // unable to work up // send back null } finally { if(gzis != null) { try { gzis.close(); } catch(IOException e) { // eat up } } if(baos != null) { try { baos.close(); } catch (IOException e) { // eat up } } } return null; }
java
private byte[] unGZip(byte[] bytes) { if(bytes == null || bytes.length == 0) { return bytes; } GZIPInputStream gzis = null; ByteArrayOutputStream baos = null; try { gzis = new GZIPInputStream(new ByteArrayInputStream(bytes)); baos = new ByteArrayOutputStream(); int len; byte[] buffer = new byte[1024]; while ((len = gzis.read(buffer)) > 0) { baos.write(buffer, 0, len); } return baos.toByteArray(); } catch(IOException e) { // unable to work up // send back null } finally { if(gzis != null) { try { gzis.close(); } catch(IOException e) { // eat up } } if(baos != null) { try { baos.close(); } catch (IOException e) { // eat up } } } return null; }
[ "private", "byte", "[", "]", "unGZip", "(", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", "==", "null", "||", "bytes", ".", "length", "==", "0", ")", "{", "return", "bytes", ";", "}", "GZIPInputStream", "gzis", "=", "null", ";", "ByteArrayOutputStream", "baos", "=", "null", ";", "try", "{", "gzis", "=", "new", "GZIPInputStream", "(", "new", "ByteArrayInputStream", "(", "bytes", ")", ")", ";", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "int", "len", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "while", "(", "(", "len", "=", "gzis", ".", "read", "(", "buffer", ")", ")", ">", "0", ")", "{", "baos", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "return", "baos", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// unable to work up", "// send back null", "}", "finally", "{", "if", "(", "gzis", "!=", "null", ")", "{", "try", "{", "gzis", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// eat up", "}", "}", "if", "(", "baos", "!=", "null", ")", "{", "try", "{", "baos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// eat up", "}", "}", "}", "return", "null", ";", "}" ]
UnGZIP a given byte stream. @param bytes the byte-stream to unGZIP @return the unGZIPed byte-array
[ "UnGZIP", "a", "given", "byte", "stream", "." ]
f0d02a5d6e7d1c15292509ce588caf52a4ddb895
https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L267-L309
153,233
sangupta/jerry-web
src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java
JavascriptMinificationFilter.isGZip
private boolean isGZip(byte[] bytes) { if(bytes == null || bytes.length == 0) { return false; } // refer http://www.gzip.org/zlib/rfc-gzip.html#file-format for magic numbers if(bytes[0] == 31 && (bytes[1] == 0x8b || bytes[1] == -117)) { return true; } return false; }
java
private boolean isGZip(byte[] bytes) { if(bytes == null || bytes.length == 0) { return false; } // refer http://www.gzip.org/zlib/rfc-gzip.html#file-format for magic numbers if(bytes[0] == 31 && (bytes[1] == 0x8b || bytes[1] == -117)) { return true; } return false; }
[ "private", "boolean", "isGZip", "(", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", "==", "null", "||", "bytes", ".", "length", "==", "0", ")", "{", "return", "false", ";", "}", "// refer http://www.gzip.org/zlib/rfc-gzip.html#file-format for magic numbers", "if", "(", "bytes", "[", "0", "]", "==", "31", "&&", "(", "bytes", "[", "1", "]", "==", "0x8b", "||", "bytes", "[", "1", "]", "==", "-", "117", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a byte stream is GZIP compressed or not. @param bytes the byte-array representing the stream @return <code>true</code> if its compressed with GZIP, <code>false</code> otherwise
[ "Check", "if", "a", "byte", "stream", "is", "GZIP", "compressed", "or", "not", "." ]
f0d02a5d6e7d1c15292509ce588caf52a4ddb895
https://github.com/sangupta/jerry-web/blob/f0d02a5d6e7d1c15292509ce588caf52a4ddb895/src/main/java/com/sangupta/jerry/web/filters/JavascriptMinificationFilter.java#L320-L331
153,234
JM-Lab/utils-java9
src/main/java/kr/jm/utils/flow/publisher/BulkSubmissionPublisher.java
BulkSubmissionPublisher.submitSingle
public int submitSingle(T item) { if (Objects.isNull(item)) return 0; synchronized (this.dataList) { this.dataList.add(item); setLastDataTimestamp(); if (this.dataList.size() >= this.bulkSize) flush(); return 1; } }
java
public int submitSingle(T item) { if (Objects.isNull(item)) return 0; synchronized (this.dataList) { this.dataList.add(item); setLastDataTimestamp(); if (this.dataList.size() >= this.bulkSize) flush(); return 1; } }
[ "public", "int", "submitSingle", "(", "T", "item", ")", "{", "if", "(", "Objects", ".", "isNull", "(", "item", ")", ")", "return", "0", ";", "synchronized", "(", "this", ".", "dataList", ")", "{", "this", ".", "dataList", ".", "add", "(", "item", ")", ";", "setLastDataTimestamp", "(", ")", ";", "if", "(", "this", ".", "dataList", ".", "size", "(", ")", ">=", "this", ".", "bulkSize", ")", "flush", "(", ")", ";", "return", "1", ";", "}", "}" ]
Submit single int. @param item the item @return the int
[ "Submit", "single", "int", "." ]
ee80235b2760396a616cf7563cbdc98d4affe8e1
https://github.com/JM-Lab/utils-java9/blob/ee80235b2760396a616cf7563cbdc98d4affe8e1/src/main/java/kr/jm/utils/flow/publisher/BulkSubmissionPublisher.java#L149-L159
153,235
microfocus-idol/java-content-parameter-api
src/main/java/com/hp/autonomy/aci/content/printfields/PrintFields.java
PrintFields.parse
public static PrintFields parse(final String printFields) { Validate.notNull(printFields, "PrintFields must not be null"); final Set<String> printFieldsSet = new LinkedHashSet<String>(Arrays.asList(SEPARATORS.split(printFields))); printFieldsSet.remove(""); return new PrintFields(printFieldsSet); }
java
public static PrintFields parse(final String printFields) { Validate.notNull(printFields, "PrintFields must not be null"); final Set<String> printFieldsSet = new LinkedHashSet<String>(Arrays.asList(SEPARATORS.split(printFields))); printFieldsSet.remove(""); return new PrintFields(printFieldsSet); }
[ "public", "static", "PrintFields", "parse", "(", "final", "String", "printFields", ")", "{", "Validate", ".", "notNull", "(", "printFields", ",", "\"PrintFields must not be null\"", ")", ";", "final", "Set", "<", "String", ">", "printFieldsSet", "=", "new", "LinkedHashSet", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "SEPARATORS", ".", "split", "(", "printFields", ")", ")", ")", ";", "printFieldsSet", ".", "remove", "(", "\"\"", ")", ";", "return", "new", "PrintFields", "(", "printFieldsSet", ")", ";", "}" ]
Parser for a printfields string. @param printFields A valid IDOL printfields @return A parsed {@code PrintFields}
[ "Parser", "for", "a", "printfields", "string", "." ]
8d33dc633f8df2a470a571ac7694e423e7004ad0
https://github.com/microfocus-idol/java-content-parameter-api/blob/8d33dc633f8df2a470a571ac7694e423e7004ad0/src/main/java/com/hp/autonomy/aci/content/printfields/PrintFields.java#L180-L187
153,236
jbundle/jbundle
app/program/db/src/main/java/org/jbundle/app/program/db/CodeTypeField.java
CodeTypeField.getCodeType
public ClassProject.CodeType getCodeType() { String code = this.toString(); if ("THICK".equalsIgnoreCase(code)) return ClassProject.CodeType.THICK; if ("THIN".equalsIgnoreCase(code)) return ClassProject.CodeType.THIN; if ("RESOURCE_CODE".equalsIgnoreCase(code)) return ClassProject.CodeType.RESOURCE_CODE; if ("RESOURCE_PROPERTIES".equalsIgnoreCase(code)) return ClassProject.CodeType.RESOURCE_PROPERTIES; if ("INTERFACE".equalsIgnoreCase(code)) return ClassProject.CodeType.INTERFACE; return null; }
java
public ClassProject.CodeType getCodeType() { String code = this.toString(); if ("THICK".equalsIgnoreCase(code)) return ClassProject.CodeType.THICK; if ("THIN".equalsIgnoreCase(code)) return ClassProject.CodeType.THIN; if ("RESOURCE_CODE".equalsIgnoreCase(code)) return ClassProject.CodeType.RESOURCE_CODE; if ("RESOURCE_PROPERTIES".equalsIgnoreCase(code)) return ClassProject.CodeType.RESOURCE_PROPERTIES; if ("INTERFACE".equalsIgnoreCase(code)) return ClassProject.CodeType.INTERFACE; return null; }
[ "public", "ClassProject", ".", "CodeType", "getCodeType", "(", ")", "{", "String", "code", "=", "this", ".", "toString", "(", ")", ";", "if", "(", "\"THICK\"", ".", "equalsIgnoreCase", "(", "code", ")", ")", "return", "ClassProject", ".", "CodeType", ".", "THICK", ";", "if", "(", "\"THIN\"", ".", "equalsIgnoreCase", "(", "code", ")", ")", "return", "ClassProject", ".", "CodeType", ".", "THIN", ";", "if", "(", "\"RESOURCE_CODE\"", ".", "equalsIgnoreCase", "(", "code", ")", ")", "return", "ClassProject", ".", "CodeType", ".", "RESOURCE_CODE", ";", "if", "(", "\"RESOURCE_PROPERTIES\"", ".", "equalsIgnoreCase", "(", "code", ")", ")", "return", "ClassProject", ".", "CodeType", ".", "RESOURCE_PROPERTIES", ";", "if", "(", "\"INTERFACE\"", ".", "equalsIgnoreCase", "(", "code", ")", ")", "return", "ClassProject", ".", "CodeType", ".", "INTERFACE", ";", "return", "null", ";", "}" ]
GetCodeType Method.
[ "GetCodeType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/db/src/main/java/org/jbundle/app/program/db/CodeTypeField.java#L73-L87
153,237
jbundle/jbundle
app/program/db/src/main/java/org/jbundle/app/program/db/CodeTypeField.java
CodeTypeField.setCodeType
public int setCodeType(ClassProject.CodeType codeType) { String codeString = null; if (codeType == ClassProject.CodeType.THICK) codeString = "THICK"; if (codeType == ClassProject.CodeType.THIN) codeString = "THIN"; if (codeType == ClassProject.CodeType.RESOURCE_CODE) codeString = "RESOURCE_CODE"; if (codeType == ClassProject.CodeType.RESOURCE_PROPERTIES) codeString = "RESOURCE_PROPERTIES"; if (codeType == ClassProject.CodeType.INTERFACE) codeString = "INTERFACE"; return this.setString(codeString); }
java
public int setCodeType(ClassProject.CodeType codeType) { String codeString = null; if (codeType == ClassProject.CodeType.THICK) codeString = "THICK"; if (codeType == ClassProject.CodeType.THIN) codeString = "THIN"; if (codeType == ClassProject.CodeType.RESOURCE_CODE) codeString = "RESOURCE_CODE"; if (codeType == ClassProject.CodeType.RESOURCE_PROPERTIES) codeString = "RESOURCE_PROPERTIES"; if (codeType == ClassProject.CodeType.INTERFACE) codeString = "INTERFACE"; return this.setString(codeString); }
[ "public", "int", "setCodeType", "(", "ClassProject", ".", "CodeType", "codeType", ")", "{", "String", "codeString", "=", "null", ";", "if", "(", "codeType", "==", "ClassProject", ".", "CodeType", ".", "THICK", ")", "codeString", "=", "\"THICK\"", ";", "if", "(", "codeType", "==", "ClassProject", ".", "CodeType", ".", "THIN", ")", "codeString", "=", "\"THIN\"", ";", "if", "(", "codeType", "==", "ClassProject", ".", "CodeType", ".", "RESOURCE_CODE", ")", "codeString", "=", "\"RESOURCE_CODE\"", ";", "if", "(", "codeType", "==", "ClassProject", ".", "CodeType", ".", "RESOURCE_PROPERTIES", ")", "codeString", "=", "\"RESOURCE_PROPERTIES\"", ";", "if", "(", "codeType", "==", "ClassProject", ".", "CodeType", ".", "INTERFACE", ")", "codeString", "=", "\"INTERFACE\"", ";", "return", "this", ".", "setString", "(", "codeString", ")", ";", "}" ]
SetCodeType Method.
[ "SetCodeType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/db/src/main/java/org/jbundle/app/program/db/CodeTypeField.java#L91-L105
153,238
danhawkes/thresher
src/main/java/co/arcs/groove/thresher/Client.java
Client.sendRequest
JsonNode sendRequest(RequestBuilder requestBuilder) throws IOException, GroovesharkException { createSessionIfRequired(); session.createCommsTokenAsRequired(); boolean sessionAlreadyRenewed = false; boolean commsTokenAlreadyRenewed = false; while (true) { // Renew out of date session/token if (!sessionAlreadyRenewed) { createSessionIfRequired(); } if (!commsTokenAlreadyRenewed) { session.createCommsTokenAsRequired(); } HttpPost httpRequest = requestBuilder.build(session); try { JsonNode jsonNode = executeRequest(httpRequest); // Handle fault codes from the API GroovesharkException exception = mapGroovesharkFaultCodeToException(jsonNode); if (exception != null) { if (exception instanceof GroovesharkException.InvalidSessionException) { // Attempt to renew session and retry if (sessionAlreadyRenewed) { throw new GroovesharkException.ServerErrorException( "Failed with invalid session. Renewed session still invalid."); } else { createSession(); sessionAlreadyRenewed = true; continue; } } else if (exception instanceof GroovesharkException.InvalidCommsTokenException) { // Attempt to renew token and retry if (commsTokenAlreadyRenewed) { throw new GroovesharkException.ServerErrorException( "Failed with invalid comms token. Renewed token also invalid."); } else { session.createCommsToken(); commsTokenAlreadyRenewed = true; continue; } } else { // The exception can't be handled internally throw exception; } } return jsonNode; } finally { // Finished with connection at this point, so make it reuseable httpRequest.reset(); } } }
java
JsonNode sendRequest(RequestBuilder requestBuilder) throws IOException, GroovesharkException { createSessionIfRequired(); session.createCommsTokenAsRequired(); boolean sessionAlreadyRenewed = false; boolean commsTokenAlreadyRenewed = false; while (true) { // Renew out of date session/token if (!sessionAlreadyRenewed) { createSessionIfRequired(); } if (!commsTokenAlreadyRenewed) { session.createCommsTokenAsRequired(); } HttpPost httpRequest = requestBuilder.build(session); try { JsonNode jsonNode = executeRequest(httpRequest); // Handle fault codes from the API GroovesharkException exception = mapGroovesharkFaultCodeToException(jsonNode); if (exception != null) { if (exception instanceof GroovesharkException.InvalidSessionException) { // Attempt to renew session and retry if (sessionAlreadyRenewed) { throw new GroovesharkException.ServerErrorException( "Failed with invalid session. Renewed session still invalid."); } else { createSession(); sessionAlreadyRenewed = true; continue; } } else if (exception instanceof GroovesharkException.InvalidCommsTokenException) { // Attempt to renew token and retry if (commsTokenAlreadyRenewed) { throw new GroovesharkException.ServerErrorException( "Failed with invalid comms token. Renewed token also invalid."); } else { session.createCommsToken(); commsTokenAlreadyRenewed = true; continue; } } else { // The exception can't be handled internally throw exception; } } return jsonNode; } finally { // Finished with connection at this point, so make it reuseable httpRequest.reset(); } } }
[ "JsonNode", "sendRequest", "(", "RequestBuilder", "requestBuilder", ")", "throws", "IOException", ",", "GroovesharkException", "{", "createSessionIfRequired", "(", ")", ";", "session", ".", "createCommsTokenAsRequired", "(", ")", ";", "boolean", "sessionAlreadyRenewed", "=", "false", ";", "boolean", "commsTokenAlreadyRenewed", "=", "false", ";", "while", "(", "true", ")", "{", "// Renew out of date session/token", "if", "(", "!", "sessionAlreadyRenewed", ")", "{", "createSessionIfRequired", "(", ")", ";", "}", "if", "(", "!", "commsTokenAlreadyRenewed", ")", "{", "session", ".", "createCommsTokenAsRequired", "(", ")", ";", "}", "HttpPost", "httpRequest", "=", "requestBuilder", ".", "build", "(", "session", ")", ";", "try", "{", "JsonNode", "jsonNode", "=", "executeRequest", "(", "httpRequest", ")", ";", "// Handle fault codes from the API", "GroovesharkException", "exception", "=", "mapGroovesharkFaultCodeToException", "(", "jsonNode", ")", ";", "if", "(", "exception", "!=", "null", ")", "{", "if", "(", "exception", "instanceof", "GroovesharkException", ".", "InvalidSessionException", ")", "{", "// Attempt to renew session and retry", "if", "(", "sessionAlreadyRenewed", ")", "{", "throw", "new", "GroovesharkException", ".", "ServerErrorException", "(", "\"Failed with invalid session. Renewed session still invalid.\"", ")", ";", "}", "else", "{", "createSession", "(", ")", ";", "sessionAlreadyRenewed", "=", "true", ";", "continue", ";", "}", "}", "else", "if", "(", "exception", "instanceof", "GroovesharkException", ".", "InvalidCommsTokenException", ")", "{", "// Attempt to renew token and retry", "if", "(", "commsTokenAlreadyRenewed", ")", "{", "throw", "new", "GroovesharkException", ".", "ServerErrorException", "(", "\"Failed with invalid comms token. Renewed token also invalid.\"", ")", ";", "}", "else", "{", "session", ".", "createCommsToken", "(", ")", ";", "commsTokenAlreadyRenewed", "=", "true", ";", "continue", ";", "}", "}", "else", "{", "// The exception can't be handled internally", "throw", "exception", ";", "}", "}", "return", "jsonNode", ";", "}", "finally", "{", "// Finished with connection at this point, so make it reuseable", "httpRequest", ".", "reset", "(", ")", ";", "}", "}", "}" ]
Sends a request, and keeps the connection open for re-use. @param requestBuilder @return JSON node containing the response body. @throws IOException @throws GroovesharkException
[ "Sends", "a", "request", "and", "keeps", "the", "connection", "open", "for", "re", "-", "use", "." ]
30e5ca62ceca3be20e47a043eedc152f8914d6b4
https://github.com/danhawkes/thresher/blob/30e5ca62ceca3be20e47a043eedc152f8914d6b4/src/main/java/co/arcs/groove/thresher/Client.java#L75-L131
153,239
danhawkes/thresher
src/main/java/co/arcs/groove/thresher/Client.java
Client.executeRequest
private JsonNode executeRequest(HttpPost request) throws IOException, GroovesharkException { HttpResponse response = httpClient.execute(request); if (debugLogging) { logRequest(request, response); } String responsePayload = CharStreams.toString(new InputStreamReader(response.getEntity() .getContent(), Charsets.UTF_8)); // Parse response JSON try { return jsonMapper.readTree(new StringReader(responsePayload)); } catch (JsonProcessingException e) { throw new GroovesharkException.ServerErrorException( "Failed to parse response - received data was not valid JSON: " + responsePayload); } }
java
private JsonNode executeRequest(HttpPost request) throws IOException, GroovesharkException { HttpResponse response = httpClient.execute(request); if (debugLogging) { logRequest(request, response); } String responsePayload = CharStreams.toString(new InputStreamReader(response.getEntity() .getContent(), Charsets.UTF_8)); // Parse response JSON try { return jsonMapper.readTree(new StringReader(responsePayload)); } catch (JsonProcessingException e) { throw new GroovesharkException.ServerErrorException( "Failed to parse response - received data was not valid JSON: " + responsePayload); } }
[ "private", "JsonNode", "executeRequest", "(", "HttpPost", "request", ")", "throws", "IOException", ",", "GroovesharkException", "{", "HttpResponse", "response", "=", "httpClient", ".", "execute", "(", "request", ")", ";", "if", "(", "debugLogging", ")", "{", "logRequest", "(", "request", ",", "response", ")", ";", "}", "String", "responsePayload", "=", "CharStreams", ".", "toString", "(", "new", "InputStreamReader", "(", "response", ".", "getEntity", "(", ")", ".", "getContent", "(", ")", ",", "Charsets", ".", "UTF_8", ")", ")", ";", "// Parse response JSON", "try", "{", "return", "jsonMapper", ".", "readTree", "(", "new", "StringReader", "(", "responsePayload", ")", ")", ";", "}", "catch", "(", "JsonProcessingException", "e", ")", "{", "throw", "new", "GroovesharkException", ".", "ServerErrorException", "(", "\"Failed to parse response - received data was not valid JSON: \"", "+", "responsePayload", ")", ";", "}", "}" ]
Boilerplate to send the request and parse the response payload as JSON.
[ "Boilerplate", "to", "send", "the", "request", "and", "parse", "the", "response", "payload", "as", "JSON", "." ]
30e5ca62ceca3be20e47a043eedc152f8914d6b4
https://github.com/danhawkes/thresher/blob/30e5ca62ceca3be20e47a043eedc152f8914d6b4/src/main/java/co/arcs/groove/thresher/Client.java#L136-L154
153,240
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/action/BaseAction.java
BaseAction.init
public void init(String actionKey, ActionListener targetListener) { m_targetListener = targetListener; m_actionKey = actionKey; String text = BaseApplet.getSharedInstance().getString(actionKey); String desc = BaseApplet.getSharedInstance().getString(actionKey + TIP); ImageIcon icon = BaseApplet.getSharedInstance().loadImageIcon(actionKey); ActionManager.getActionManager().put(actionKey, this); this.putValue(AbstractAction.NAME, text); if (desc != null) if (!desc.equalsIgnoreCase(actionKey + TIP)) this.putValue(AbstractAction.SHORT_DESCRIPTION, desc); if (icon != null) this.putValue(AbstractAction.SMALL_ICON, icon); }
java
public void init(String actionKey, ActionListener targetListener) { m_targetListener = targetListener; m_actionKey = actionKey; String text = BaseApplet.getSharedInstance().getString(actionKey); String desc = BaseApplet.getSharedInstance().getString(actionKey + TIP); ImageIcon icon = BaseApplet.getSharedInstance().loadImageIcon(actionKey); ActionManager.getActionManager().put(actionKey, this); this.putValue(AbstractAction.NAME, text); if (desc != null) if (!desc.equalsIgnoreCase(actionKey + TIP)) this.putValue(AbstractAction.SHORT_DESCRIPTION, desc); if (icon != null) this.putValue(AbstractAction.SMALL_ICON, icon); }
[ "public", "void", "init", "(", "String", "actionKey", ",", "ActionListener", "targetListener", ")", "{", "m_targetListener", "=", "targetListener", ";", "m_actionKey", "=", "actionKey", ";", "String", "text", "=", "BaseApplet", ".", "getSharedInstance", "(", ")", ".", "getString", "(", "actionKey", ")", ";", "String", "desc", "=", "BaseApplet", ".", "getSharedInstance", "(", ")", ".", "getString", "(", "actionKey", "+", "TIP", ")", ";", "ImageIcon", "icon", "=", "BaseApplet", ".", "getSharedInstance", "(", ")", ".", "loadImageIcon", "(", "actionKey", ")", ";", "ActionManager", ".", "getActionManager", "(", ")", ".", "put", "(", "actionKey", ",", "this", ")", ";", "this", ".", "putValue", "(", "AbstractAction", ".", "NAME", ",", "text", ")", ";", "if", "(", "desc", "!=", "null", ")", "if", "(", "!", "desc", ".", "equalsIgnoreCase", "(", "actionKey", "+", "TIP", ")", ")", "this", ".", "putValue", "(", "AbstractAction", ".", "SHORT_DESCRIPTION", ",", "desc", ")", ";", "if", "(", "icon", "!=", "null", ")", "this", ".", "putValue", "(", "AbstractAction", ".", "SMALL_ICON", ",", "icon", ")", ";", "}" ]
Creates a new instance of BaseAction. @param actionKey The menu description key for this item.
[ "Creates", "a", "new", "instance", "of", "BaseAction", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/action/BaseAction.java#L56-L73
153,241
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertStringPropertyEquals
public static void assertStringPropertyEquals(final Node node, final String propertyName, final String actualValue) throws RepositoryException { assertTrue("Node " + node.getPath() + " has no property " + propertyName, node.hasProperty(propertyName)); final Property prop = node.getProperty(propertyName); assertEquals("Property type is not STRING ", PropertyType.STRING, prop.getType()); assertEquals(actualValue, prop.getString()); }
java
public static void assertStringPropertyEquals(final Node node, final String propertyName, final String actualValue) throws RepositoryException { assertTrue("Node " + node.getPath() + " has no property " + propertyName, node.hasProperty(propertyName)); final Property prop = node.getProperty(propertyName); assertEquals("Property type is not STRING ", PropertyType.STRING, prop.getType()); assertEquals(actualValue, prop.getString()); }
[ "public", "static", "void", "assertStringPropertyEquals", "(", "final", "Node", "node", ",", "final", "String", "propertyName", ",", "final", "String", "actualValue", ")", "throws", "RepositoryException", "{", "assertTrue", "(", "\"Node \"", "+", "node", ".", "getPath", "(", ")", "+", "\" has no property \"", "+", "propertyName", ",", "node", ".", "hasProperty", "(", "propertyName", ")", ")", ";", "final", "Property", "prop", "=", "node", ".", "getProperty", "(", "propertyName", ")", ";", "assertEquals", "(", "\"Property type is not STRING \"", ",", "PropertyType", ".", "STRING", ",", "prop", ".", "getType", "(", ")", ")", ";", "assertEquals", "(", "actualValue", ",", "prop", ".", "getString", "(", ")", ")", ";", "}" ]
Asserts the equality of a property value of a node with an expected value @param node the node containing the property to be verified @param propertyName the property name to be verified @param actualValue the actual value that should be compared to the propert node @throws RepositoryException
[ "Asserts", "the", "equality", "of", "a", "property", "value", "of", "a", "node", "with", "an", "expected", "value" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L62-L68
153,242
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeExistByPath
public static void assertNodeExistByPath(final Session session, final String absPath) throws RepositoryException { try { session.getNode(absPath); } catch (final PathNotFoundException e) { LOG.debug("Node path {} does not exist", absPath, e); fail(e.getMessage()); } }
java
public static void assertNodeExistByPath(final Session session, final String absPath) throws RepositoryException { try { session.getNode(absPath); } catch (final PathNotFoundException e) { LOG.debug("Node path {} does not exist", absPath, e); fail(e.getMessage()); } }
[ "public", "static", "void", "assertNodeExistByPath", "(", "final", "Session", "session", ",", "final", "String", "absPath", ")", "throws", "RepositoryException", "{", "try", "{", "session", ".", "getNode", "(", "absPath", ")", ";", "}", "catch", "(", "final", "PathNotFoundException", "e", ")", "{", "LOG", ".", "debug", "(", "\"Node path {} does not exist\"", ",", "absPath", ",", "e", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Asserts that a specific node with the given absolute path exists in the session @param session the session to search for the node @param absPath the absolute path to look for a node @throws RepositoryException if the repository access failed
[ "Asserts", "that", "a", "specific", "node", "with", "the", "given", "absolute", "path", "exists", "in", "the", "session" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L80-L87
153,243
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeNotExistByPath
public static void assertNodeNotExistByPath(final Session session, final String absPath) throws RepositoryException { try { session.getNode(absPath); fail("Node " + absPath + " does not exist"); } catch (final PathNotFoundException e) { // NOSONAR // the exception is expected } }
java
public static void assertNodeNotExistByPath(final Session session, final String absPath) throws RepositoryException { try { session.getNode(absPath); fail("Node " + absPath + " does not exist"); } catch (final PathNotFoundException e) { // NOSONAR // the exception is expected } }
[ "public", "static", "void", "assertNodeNotExistByPath", "(", "final", "Session", "session", ",", "final", "String", "absPath", ")", "throws", "RepositoryException", "{", "try", "{", "session", ".", "getNode", "(", "absPath", ")", ";", "fail", "(", "\"Node \"", "+", "absPath", "+", "\" does not exist\"", ")", ";", "}", "catch", "(", "final", "PathNotFoundException", "e", ")", "{", "// NOSONAR", "// the exception is expected", "}", "}" ]
Asserts that a specific node with the given absolute path does not exist in the session @param session the session to search for the node @param absPath the absolute path to look for a node @throws RepositoryException if the repository access failed
[ "Asserts", "that", "a", "specific", "node", "with", "the", "given", "absolute", "path", "does", "not", "exist", "in", "the", "session" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L99-L106
153,244
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeExistById
public static void assertNodeExistById(final Session session, final String itemId) throws RepositoryException { try { session.getNodeByIdentifier(itemId); } catch (final ItemNotFoundException e) { LOG.debug("Item with id {} does not exist", itemId, e); fail(e.getMessage()); } }
java
public static void assertNodeExistById(final Session session, final String itemId) throws RepositoryException { try { session.getNodeByIdentifier(itemId); } catch (final ItemNotFoundException e) { LOG.debug("Item with id {} does not exist", itemId, e); fail(e.getMessage()); } }
[ "public", "static", "void", "assertNodeExistById", "(", "final", "Session", "session", ",", "final", "String", "itemId", ")", "throws", "RepositoryException", "{", "try", "{", "session", ".", "getNodeByIdentifier", "(", "itemId", ")", ";", "}", "catch", "(", "final", "ItemNotFoundException", "e", ")", "{", "LOG", ".", "debug", "(", "\"Item with id {} does not exist\"", ",", "itemId", ",", "e", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Asserts that an item, identified by it's unique id, is found in the repository session. @param session the session to be searched @param itemId the item expected to be found @throws RepositoryException
[ "Asserts", "that", "an", "item", "identified", "by", "it", "s", "unique", "id", "is", "found", "in", "the", "repository", "session", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L117-L124
153,245
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeNotExistById
public static void assertNodeNotExistById(final Session session, final String itemId) throws RepositoryException { try { session.getNodeByIdentifier(itemId); fail("ItemNotFoundException expected"); } catch (final ItemNotFoundException e) { // NOSONAR // this was expected } }
java
public static void assertNodeNotExistById(final Session session, final String itemId) throws RepositoryException { try { session.getNodeByIdentifier(itemId); fail("ItemNotFoundException expected"); } catch (final ItemNotFoundException e) { // NOSONAR // this was expected } }
[ "public", "static", "void", "assertNodeNotExistById", "(", "final", "Session", "session", ",", "final", "String", "itemId", ")", "throws", "RepositoryException", "{", "try", "{", "session", ".", "getNodeByIdentifier", "(", "itemId", ")", ";", "fail", "(", "\"ItemNotFoundException expected\"", ")", ";", "}", "catch", "(", "final", "ItemNotFoundException", "e", ")", "{", "// NOSONAR", "// this was expected", "}", "}" ]
Asserts that an item, identified by it's unique id, is not found in the repository session. @param session the session to be searched @param itemId the item expected not to be found @throws RepositoryException
[ "Asserts", "that", "an", "item", "identified", "by", "it", "s", "unique", "id", "is", "not", "found", "in", "the", "repository", "session", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L135-L142
153,246
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeExist
public static void assertNodeExist(final Node rootNode, final String relPath) throws RepositoryException { try { rootNode.getNode(relPath); } catch (final PathNotFoundException e) { LOG.debug("Node {} does not exist in path {}", relPath, rootNode.getPath(), e); fail(e.getMessage()); } }
java
public static void assertNodeExist(final Node rootNode, final String relPath) throws RepositoryException { try { rootNode.getNode(relPath); } catch (final PathNotFoundException e) { LOG.debug("Node {} does not exist in path {}", relPath, rootNode.getPath(), e); fail(e.getMessage()); } }
[ "public", "static", "void", "assertNodeExist", "(", "final", "Node", "rootNode", ",", "final", "String", "relPath", ")", "throws", "RepositoryException", "{", "try", "{", "rootNode", ".", "getNode", "(", "relPath", ")", ";", "}", "catch", "(", "final", "PathNotFoundException", "e", ")", "{", "LOG", ".", "debug", "(", "\"Node {} does not exist in path {}\"", ",", "relPath", ",", "rootNode", ".", "getPath", "(", ")", ",", "e", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Asserts that a specific node exists under the root node, where the specific node is specified using its relative path @param rootNode the root Node to start the search @param relPath the relative path of the node that is asserted to exist @throws RepositoryException if the repository access failed
[ "Asserts", "that", "a", "specific", "node", "exists", "under", "the", "root", "node", "where", "the", "specific", "node", "is", "specified", "using", "its", "relative", "path" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L155-L162
153,247
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertPrimaryNodeType
public static void assertPrimaryNodeType(final Node node, final String nodeType) throws RepositoryException { final NodeType primaryNodeType = node.getPrimaryNodeType(); assertEquals(nodeType, primaryNodeType.getName()); }
java
public static void assertPrimaryNodeType(final Node node, final String nodeType) throws RepositoryException { final NodeType primaryNodeType = node.getPrimaryNodeType(); assertEquals(nodeType, primaryNodeType.getName()); }
[ "public", "static", "void", "assertPrimaryNodeType", "(", "final", "Node", "node", ",", "final", "String", "nodeType", ")", "throws", "RepositoryException", "{", "final", "NodeType", "primaryNodeType", "=", "node", ".", "getPrimaryNodeType", "(", ")", ";", "assertEquals", "(", "nodeType", ",", "primaryNodeType", ".", "getName", "(", ")", ")", ";", "}" ]
Asserts the primary node type of the node @param node the node whose primary node type should be checked @param nodeType the nodetype that is asserted to be the node type of the node @throws RepositoryException
[ "Asserts", "the", "primary", "node", "type", "of", "the", "node" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L173-L176
153,248
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertMixinNodeType
public static void assertMixinNodeType(final Node node, final String mixinType) throws RepositoryException { for (final NodeType nt : node.getMixinNodeTypes()) { if (mixinType.equals(nt.getName())) { return; } } fail("Node " + node.getPath() + " has no mixin type " + mixinType); }
java
public static void assertMixinNodeType(final Node node, final String mixinType) throws RepositoryException { for (final NodeType nt : node.getMixinNodeTypes()) { if (mixinType.equals(nt.getName())) { return; } } fail("Node " + node.getPath() + " has no mixin type " + mixinType); }
[ "public", "static", "void", "assertMixinNodeType", "(", "final", "Node", "node", ",", "final", "String", "mixinType", ")", "throws", "RepositoryException", "{", "for", "(", "final", "NodeType", "nt", ":", "node", ".", "getMixinNodeTypes", "(", ")", ")", "{", "if", "(", "mixinType", ".", "equals", "(", "nt", ".", "getName", "(", ")", ")", ")", "{", "return", ";", "}", "}", "fail", "(", "\"Node \"", "+", "node", ".", "getPath", "(", ")", "+", "\" has no mixin type \"", "+", "mixinType", ")", ";", "}" ]
Asserts one of the node's mixin type equals the specified nodetype @param node the node whose mixin types should be checked @param mixinType the node type that is asserted to be one of the mixin types of the node @throws RepositoryException
[ "Asserts", "one", "of", "the", "node", "s", "mixin", "type", "equals", "the", "specified", "nodetype" ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L187-L194
153,249
inkstand-io/scribble
scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java
JCRAssert.assertNodeTypeExists
public static void assertNodeTypeExists(final Session session, final String nodeTypeName) throws RepositoryException { final NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager(); assertTrue("NodeType " + nodeTypeName + " does not exist", ntm.hasNodeType(nodeTypeName)); }
java
public static void assertNodeTypeExists(final Session session, final String nodeTypeName) throws RepositoryException { final NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager(); assertTrue("NodeType " + nodeTypeName + " does not exist", ntm.hasNodeType(nodeTypeName)); }
[ "public", "static", "void", "assertNodeTypeExists", "(", "final", "Session", "session", ",", "final", "String", "nodeTypeName", ")", "throws", "RepositoryException", "{", "final", "NodeTypeManager", "ntm", "=", "session", ".", "getWorkspace", "(", ")", ".", "getNodeTypeManager", "(", ")", ";", "assertTrue", "(", "\"NodeType \"", "+", "nodeTypeName", "+", "\" does not exist\"", ",", "ntm", ".", "hasNodeType", "(", "nodeTypeName", ")", ")", ";", "}" ]
Asserts that a specific node type is registered in the workspace of the session. @param session the session to perform the lookup @param nodeTypeName the name of the nodetype that is asserted to exist @throws RepositoryException if an error occurs
[ "Asserts", "that", "a", "specific", "node", "type", "is", "registered", "in", "the", "workspace", "of", "the", "session", "." ]
66e67553bad4b1ff817e1715fd1d3dd833406744
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-jcr/src/main/java/io/inkstand/scribble/jcr/JCRAssert.java#L206-L211
153,250
jbundle/jbundle
thin/base/thread/src/main/java/org/jbundle/thin/base/thread/TaskScheduler.java
TaskScheduler.runThread
@SuppressWarnings({ "rawtypes", "unchecked" }) public void runThread(Object objJobDef) { if (objJobDef instanceof Task) { Task task = (Task)objJobDef; if (task.getApplication() == null) // init()ed yet? task.initTask(this.getApplication(), null); // No, Initialize it task.run(); } else if ((objJobDef instanceof String) || (objJobDef instanceof Properties)) { String strJobDef = null; Map<String,Object> properties = null; if (objJobDef instanceof String) { strJobDef = (String)objJobDef; properties = new Hashtable<String,Object>(); Util.parseArgs(properties, strJobDef); } if (objJobDef instanceof Properties) properties = (Map)objJobDef; if (properties.get("webStartPropertiesFile") != null) properties = this.addPropertiesFile(properties); String strClass = (String)properties.get(Param.TASK); if (strClass == null) strClass = (String)properties.get(Param.APPLET); // Applets are also run as tasks Object job = ClassServiceUtility.getClassService().makeObjectFromClassName(strClass); if (job instanceof Task) { ((Task)job).initTask(this.getApplication(), properties); ((Task)job).run(); } else if (job instanceof Applet) { // An applet //new JBaseFrame("Applet", (Applet)job); System.out.println("********** Applet task type needs to be fixed *********"); } else if (job instanceof Runnable) { // A thread (Is this okay?? I already have my own thread) //x new Thread((Runnable)job).start(); // No, don't start another thread ((Runnable)job).run(); // This should be okay, as I already have my own thread } else Util.getLogger().warning("Illegal job type passed to TaskScheduler: " + job); } else if (objJobDef instanceof Runnable) ((Runnable)objJobDef).run(); else Util.getLogger().warning("Error: Illegal job type"); }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void runThread(Object objJobDef) { if (objJobDef instanceof Task) { Task task = (Task)objJobDef; if (task.getApplication() == null) // init()ed yet? task.initTask(this.getApplication(), null); // No, Initialize it task.run(); } else if ((objJobDef instanceof String) || (objJobDef instanceof Properties)) { String strJobDef = null; Map<String,Object> properties = null; if (objJobDef instanceof String) { strJobDef = (String)objJobDef; properties = new Hashtable<String,Object>(); Util.parseArgs(properties, strJobDef); } if (objJobDef instanceof Properties) properties = (Map)objJobDef; if (properties.get("webStartPropertiesFile") != null) properties = this.addPropertiesFile(properties); String strClass = (String)properties.get(Param.TASK); if (strClass == null) strClass = (String)properties.get(Param.APPLET); // Applets are also run as tasks Object job = ClassServiceUtility.getClassService().makeObjectFromClassName(strClass); if (job instanceof Task) { ((Task)job).initTask(this.getApplication(), properties); ((Task)job).run(); } else if (job instanceof Applet) { // An applet //new JBaseFrame("Applet", (Applet)job); System.out.println("********** Applet task type needs to be fixed *********"); } else if (job instanceof Runnable) { // A thread (Is this okay?? I already have my own thread) //x new Thread((Runnable)job).start(); // No, don't start another thread ((Runnable)job).run(); // This should be okay, as I already have my own thread } else Util.getLogger().warning("Illegal job type passed to TaskScheduler: " + job); } else if (objJobDef instanceof Runnable) ((Runnable)objJobDef).run(); else Util.getLogger().warning("Error: Illegal job type"); }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "void", "runThread", "(", "Object", "objJobDef", ")", "{", "if", "(", "objJobDef", "instanceof", "Task", ")", "{", "Task", "task", "=", "(", "Task", ")", "objJobDef", ";", "if", "(", "task", ".", "getApplication", "(", ")", "==", "null", ")", "// init()ed yet?", "task", ".", "initTask", "(", "this", ".", "getApplication", "(", ")", ",", "null", ")", ";", "// No, Initialize it", "task", ".", "run", "(", ")", ";", "}", "else", "if", "(", "(", "objJobDef", "instanceof", "String", ")", "||", "(", "objJobDef", "instanceof", "Properties", ")", ")", "{", "String", "strJobDef", "=", "null", ";", "Map", "<", "String", ",", "Object", ">", "properties", "=", "null", ";", "if", "(", "objJobDef", "instanceof", "String", ")", "{", "strJobDef", "=", "(", "String", ")", "objJobDef", ";", "properties", "=", "new", "Hashtable", "<", "String", ",", "Object", ">", "(", ")", ";", "Util", ".", "parseArgs", "(", "properties", ",", "strJobDef", ")", ";", "}", "if", "(", "objJobDef", "instanceof", "Properties", ")", "properties", "=", "(", "Map", ")", "objJobDef", ";", "if", "(", "properties", ".", "get", "(", "\"webStartPropertiesFile\"", ")", "!=", "null", ")", "properties", "=", "this", ".", "addPropertiesFile", "(", "properties", ")", ";", "String", "strClass", "=", "(", "String", ")", "properties", ".", "get", "(", "Param", ".", "TASK", ")", ";", "if", "(", "strClass", "==", "null", ")", "strClass", "=", "(", "String", ")", "properties", ".", "get", "(", "Param", ".", "APPLET", ")", ";", "// Applets are also run as tasks", "Object", "job", "=", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "makeObjectFromClassName", "(", "strClass", ")", ";", "if", "(", "job", "instanceof", "Task", ")", "{", "(", "(", "Task", ")", "job", ")", ".", "initTask", "(", "this", ".", "getApplication", "(", ")", ",", "properties", ")", ";", "(", "(", "Task", ")", "job", ")", ".", "run", "(", ")", ";", "}", "else", "if", "(", "job", "instanceof", "Applet", ")", "{", "// An applet", "//new JBaseFrame(\"Applet\", (Applet)job);", "System", ".", "out", ".", "println", "(", "\"********** Applet task type needs to be fixed *********\"", ")", ";", "}", "else", "if", "(", "job", "instanceof", "Runnable", ")", "{", "// A thread (Is this okay?? I already have my own thread)", "//x new Thread((Runnable)job).start(); // No, don't start another thread", "(", "(", "Runnable", ")", "job", ")", ".", "run", "(", ")", ";", "// This should be okay, as I already have my own thread", "}", "else", "Util", ".", "getLogger", "(", ")", ".", "warning", "(", "\"Illegal job type passed to TaskScheduler: \"", "+", "job", ")", ";", "}", "else", "if", "(", "objJobDef", "instanceof", "Runnable", ")", "(", "(", "Runnable", ")", "objJobDef", ")", ".", "run", "(", ")", ";", "else", "Util", ".", "getLogger", "(", ")", ".", "warning", "(", "\"Error: Illegal job type\"", ")", ";", "}" ]
Start this task running in this thread. @param objJobDef The job to run in this thread.
[ "Start", "this", "task", "running", "in", "this", "thread", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/thread/src/main/java/org/jbundle/thin/base/thread/TaskScheduler.java#L139-L189
153,251
jbundle/jbundle
thin/base/thread/src/main/java/org/jbundle/thin/base/thread/TaskScheduler.java
TaskScheduler.startPageWorker
public static SyncWorker startPageWorker(SyncPage syncPage, SyncNotify syncNotify, Runnable swingPageLoader, Map<String,Object> map, boolean bManageCursor) { SyncWorker syncWorker = (SyncWorker)ClassServiceUtility.getClassService().makeObjectFromClassName(JAVA_WORKER); if (syncWorker == null) syncWorker = (SyncWorker)ClassServiceUtility.getClassService().makeObjectFromClassName(ANDROID_WORKER); if (syncWorker != null) { syncWorker.init(syncPage, syncNotify, swingPageLoader, map, bManageCursor); syncWorker.start(); } else Util.getLogger().severe("SyncWorker does not exist!"); return syncWorker; }
java
public static SyncWorker startPageWorker(SyncPage syncPage, SyncNotify syncNotify, Runnable swingPageLoader, Map<String,Object> map, boolean bManageCursor) { SyncWorker syncWorker = (SyncWorker)ClassServiceUtility.getClassService().makeObjectFromClassName(JAVA_WORKER); if (syncWorker == null) syncWorker = (SyncWorker)ClassServiceUtility.getClassService().makeObjectFromClassName(ANDROID_WORKER); if (syncWorker != null) { syncWorker.init(syncPage, syncNotify, swingPageLoader, map, bManageCursor); syncWorker.start(); } else Util.getLogger().severe("SyncWorker does not exist!"); return syncWorker; }
[ "public", "static", "SyncWorker", "startPageWorker", "(", "SyncPage", "syncPage", ",", "SyncNotify", "syncNotify", ",", "Runnable", "swingPageLoader", ",", "Map", "<", "String", ",", "Object", ">", "map", ",", "boolean", "bManageCursor", ")", "{", "SyncWorker", "syncWorker", "=", "(", "SyncWorker", ")", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "makeObjectFromClassName", "(", "JAVA_WORKER", ")", ";", "if", "(", "syncWorker", "==", "null", ")", "syncWorker", "=", "(", "SyncWorker", ")", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "makeObjectFromClassName", "(", "ANDROID_WORKER", ")", ";", "if", "(", "syncWorker", "!=", "null", ")", "{", "syncWorker", ".", "init", "(", "syncPage", ",", "syncNotify", ",", "swingPageLoader", ",", "map", ",", "bManageCursor", ")", ";", "syncWorker", ".", "start", "(", ")", ";", "}", "else", "Util", ".", "getLogger", "(", ")", ".", "severe", "(", "\"SyncWorker does not exist!\"", ")", ";", "return", "syncWorker", ";", "}" ]
Start a task that calls the syncNotify 'done' method when the screen is done displaying. This class is a platform-neutral implementation of SwinSyncPageWorker that guarantees a page has displayed before doing a compute-intensive task.
[ "Start", "a", "task", "that", "calls", "the", "syncNotify", "done", "method", "when", "the", "screen", "is", "done", "displaying", ".", "This", "class", "is", "a", "platform", "-", "neutral", "implementation", "of", "SwinSyncPageWorker", "that", "guarantees", "a", "page", "has", "displayed", "before", "doing", "a", "compute", "-", "intensive", "task", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/thread/src/main/java/org/jbundle/thin/base/thread/TaskScheduler.java#L279-L292
153,252
microfocus-idol/java-content-parameter-api
src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java
FieldTextBuilder.binaryOperation
private FieldTextBuilder binaryOperation(final String operator, final FieldText fieldText) { // This should never happen as the AND, OR, XOR and WHEN methods should already have checked this Validate.isTrue(fieldText != this); // Optimized case when fieldText is a FieldTextBuilder if(fieldText instanceof FieldTextBuilder) { return binaryOp(operator, (FieldTextBuilder)fieldText); } // Special case when we're empty if(componentCount == 0) { fieldTextString.append(fieldText.toString()); if(fieldText.size() > 1) { lastOperator = ""; } } else { // Add the NOTs, parentheses and operator addOperator(operator); // Size 1 means a single specifier, so no parentheses if(fieldText.size() == 1) { fieldTextString.append(fieldText.toString()); } else { fieldTextString.append('(').append(fieldText.toString()).append(')'); } } componentCount += fieldText.size(); not = false; return this; }
java
private FieldTextBuilder binaryOperation(final String operator, final FieldText fieldText) { // This should never happen as the AND, OR, XOR and WHEN methods should already have checked this Validate.isTrue(fieldText != this); // Optimized case when fieldText is a FieldTextBuilder if(fieldText instanceof FieldTextBuilder) { return binaryOp(operator, (FieldTextBuilder)fieldText); } // Special case when we're empty if(componentCount == 0) { fieldTextString.append(fieldText.toString()); if(fieldText.size() > 1) { lastOperator = ""; } } else { // Add the NOTs, parentheses and operator addOperator(operator); // Size 1 means a single specifier, so no parentheses if(fieldText.size() == 1) { fieldTextString.append(fieldText.toString()); } else { fieldTextString.append('(').append(fieldText.toString()).append(')'); } } componentCount += fieldText.size(); not = false; return this; }
[ "private", "FieldTextBuilder", "binaryOperation", "(", "final", "String", "operator", ",", "final", "FieldText", "fieldText", ")", "{", "// This should never happen as the AND, OR, XOR and WHEN methods should already have checked this", "Validate", ".", "isTrue", "(", "fieldText", "!=", "this", ")", ";", "// Optimized case when fieldText is a FieldTextBuilder", "if", "(", "fieldText", "instanceof", "FieldTextBuilder", ")", "{", "return", "binaryOp", "(", "operator", ",", "(", "FieldTextBuilder", ")", "fieldText", ")", ";", "}", "// Special case when we're empty", "if", "(", "componentCount", "==", "0", ")", "{", "fieldTextString", ".", "append", "(", "fieldText", ".", "toString", "(", ")", ")", ";", "if", "(", "fieldText", ".", "size", "(", ")", ">", "1", ")", "{", "lastOperator", "=", "\"\"", ";", "}", "}", "else", "{", "// Add the NOTs, parentheses and operator", "addOperator", "(", "operator", ")", ";", "// Size 1 means a single specifier, so no parentheses", "if", "(", "fieldText", ".", "size", "(", ")", "==", "1", ")", "{", "fieldTextString", ".", "append", "(", "fieldText", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "fieldTextString", ".", "append", "(", "'", "'", ")", ".", "append", "(", "fieldText", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "}", "componentCount", "+=", "fieldText", ".", "size", "(", ")", ";", "not", "=", "false", ";", "return", "this", ";", "}" ]
Does the work for the OR, AND, XOR and WHEN methods. @param operator @param fieldText @return
[ "Does", "the", "work", "for", "the", "OR", "AND", "XOR", "and", "WHEN", "methods", "." ]
8d33dc633f8df2a470a571ac7694e423e7004ad0
https://github.com/microfocus-idol/java-content-parameter-api/blob/8d33dc633f8df2a470a571ac7694e423e7004ad0/src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java#L299-L331
153,253
microfocus-idol/java-content-parameter-api
src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java
FieldTextBuilder.binaryOp
private FieldTextBuilder binaryOp(final String operator, final FieldTextBuilder fieldText) { // Special case when we're empty if(componentCount == 0) { // Just copy the argument fieldTextString.append(fieldText.fieldTextString); lastOperator = fieldText.lastOperator; not = fieldText.not; componentCount = fieldText.componentCount; } else { // Add the NOTs, parentheses and operator addOperator(operator); if(fieldText.lastOperator == null || fieldText.lastOperator.equals(operator) || fieldText.not) { fieldTextString.append(fieldText.toString()); } else { fieldTextString.append('(').append(fieldText.toString()).append(')'); } componentCount += fieldText.size(); not = false; } return this; }
java
private FieldTextBuilder binaryOp(final String operator, final FieldTextBuilder fieldText) { // Special case when we're empty if(componentCount == 0) { // Just copy the argument fieldTextString.append(fieldText.fieldTextString); lastOperator = fieldText.lastOperator; not = fieldText.not; componentCount = fieldText.componentCount; } else { // Add the NOTs, parentheses and operator addOperator(operator); if(fieldText.lastOperator == null || fieldText.lastOperator.equals(operator) || fieldText.not) { fieldTextString.append(fieldText.toString()); } else { fieldTextString.append('(').append(fieldText.toString()).append(')'); } componentCount += fieldText.size(); not = false; } return this; }
[ "private", "FieldTextBuilder", "binaryOp", "(", "final", "String", "operator", ",", "final", "FieldTextBuilder", "fieldText", ")", "{", "// Special case when we're empty", "if", "(", "componentCount", "==", "0", ")", "{", "// Just copy the argument", "fieldTextString", ".", "append", "(", "fieldText", ".", "fieldTextString", ")", ";", "lastOperator", "=", "fieldText", ".", "lastOperator", ";", "not", "=", "fieldText", ".", "not", ";", "componentCount", "=", "fieldText", ".", "componentCount", ";", "}", "else", "{", "// Add the NOTs, parentheses and operator", "addOperator", "(", "operator", ")", ";", "if", "(", "fieldText", ".", "lastOperator", "==", "null", "||", "fieldText", ".", "lastOperator", ".", "equals", "(", "operator", ")", "||", "fieldText", ".", "not", ")", "{", "fieldTextString", ".", "append", "(", "fieldText", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "fieldTextString", ".", "append", "(", "'", "'", ")", ".", "append", "(", "fieldText", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "componentCount", "+=", "fieldText", ".", "size", "(", ")", ";", "not", "=", "false", ";", "}", "return", "this", ";", "}" ]
Does the work for the OR, AND and XOR methods in the optimized case where fieldText is a FieldTextBuilder. @param operator @param fieldText @return
[ "Does", "the", "work", "for", "the", "OR", "AND", "and", "XOR", "methods", "in", "the", "optimized", "case", "where", "fieldText", "is", "a", "FieldTextBuilder", "." ]
8d33dc633f8df2a470a571ac7694e423e7004ad0
https://github.com/microfocus-idol/java-content-parameter-api/blob/8d33dc633f8df2a470a571ac7694e423e7004ad0/src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java#L340-L363
153,254
microfocus-idol/java-content-parameter-api
src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java
FieldTextBuilder.addOperator
private void addOperator(final String operator) { // This should never happen but sanity check... Validate.notNull(operator); if(lastOperator == null) { lastOperator = operator; } /* Logic to determine whether to put parentheses around the existing fieldtext. This is tied to the use of the * NOT operator as it also adds parentheses. */ if(not) { if(componentCount == 1) { fieldTextString.insert(0, "NOT+"); } else { fieldTextString.insert(0, "NOT(").append(')'); } } else if(!lastOperator.equals(operator)) { fieldTextString.insert(0, '(').append(')'); } lastOperator = operator; fieldTextString.append('+').append(operator).append('+'); }
java
private void addOperator(final String operator) { // This should never happen but sanity check... Validate.notNull(operator); if(lastOperator == null) { lastOperator = operator; } /* Logic to determine whether to put parentheses around the existing fieldtext. This is tied to the use of the * NOT operator as it also adds parentheses. */ if(not) { if(componentCount == 1) { fieldTextString.insert(0, "NOT+"); } else { fieldTextString.insert(0, "NOT(").append(')'); } } else if(!lastOperator.equals(operator)) { fieldTextString.insert(0, '(').append(')'); } lastOperator = operator; fieldTextString.append('+').append(operator).append('+'); }
[ "private", "void", "addOperator", "(", "final", "String", "operator", ")", "{", "// This should never happen but sanity check...", "Validate", ".", "notNull", "(", "operator", ")", ";", "if", "(", "lastOperator", "==", "null", ")", "{", "lastOperator", "=", "operator", ";", "}", "/* Logic to determine whether to put parentheses around the existing fieldtext. This is tied to the use of the\n * NOT operator as it also adds parentheses.\n */", "if", "(", "not", ")", "{", "if", "(", "componentCount", "==", "1", ")", "{", "fieldTextString", ".", "insert", "(", "0", ",", "\"NOT+\"", ")", ";", "}", "else", "{", "fieldTextString", ".", "insert", "(", "0", ",", "\"NOT(\"", ")", ".", "append", "(", "'", "'", ")", ";", "}", "}", "else", "if", "(", "!", "lastOperator", ".", "equals", "(", "operator", ")", ")", "{", "fieldTextString", ".", "insert", "(", "0", ",", "'", "'", ")", ".", "append", "(", "'", "'", ")", ";", "}", "lastOperator", "=", "operator", ";", "fieldTextString", ".", "append", "(", "'", "'", ")", ".", "append", "(", "operator", ")", ".", "append", "(", "'", "'", ")", ";", "}" ]
The first section of the fieldtext manipulation process, where the NOTs are handled and the operator is added, are common to both binaryOp methods so this method saves us repeating the code. @param operator
[ "The", "first", "section", "of", "the", "fieldtext", "manipulation", "process", "where", "the", "NOTs", "are", "handled", "and", "the", "operator", "is", "added", "are", "common", "to", "both", "binaryOp", "methods", "so", "this", "method", "saves", "us", "repeating", "the", "code", "." ]
8d33dc633f8df2a470a571ac7694e423e7004ad0
https://github.com/microfocus-idol/java-content-parameter-api/blob/8d33dc633f8df2a470a571ac7694e423e7004ad0/src/main/java/com/hp/autonomy/aci/content/fieldtext/FieldTextBuilder.java#L371-L395
153,255
jbundle/jbundle
base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java
RemoteSessionServer.init
public void init(App app, Rec record, Map<String,Object> properties) { m_app = app; }
java
public void init(App app, Rec record, Map<String,Object> properties) { m_app = app; }
[ "public", "void", "init", "(", "App", "app", ",", "Rec", "record", ",", "Map", "<", "String", ",", "Object", ">", "properties", ")", "{", "m_app", "=", "app", ";", "}" ]
Creates new RmiSessionServer.
[ "Creates", "new", "RmiSessionServer", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java#L69-L72
153,256
jbundle/jbundle
base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java
RemoteSessionServer.startupServer
public static RemoteSessionServer startupServer(Map<String,Object> properties) { RemoteSessionServer remoteServer = null; Utility.getLogger().info("Starting RemoteSession server"); try { remoteServer = new RemoteSessionServer(null, null, null); } catch (RemoteException ex) { ex.printStackTrace(); } return remoteServer; }
java
public static RemoteSessionServer startupServer(Map<String,Object> properties) { RemoteSessionServer remoteServer = null; Utility.getLogger().info("Starting RemoteSession server"); try { remoteServer = new RemoteSessionServer(null, null, null); } catch (RemoteException ex) { ex.printStackTrace(); } return remoteServer; }
[ "public", "static", "RemoteSessionServer", "startupServer", "(", "Map", "<", "String", ",", "Object", ">", "properties", ")", "{", "RemoteSessionServer", "remoteServer", "=", "null", ";", "Utility", ".", "getLogger", "(", ")", ".", "info", "(", "\"Starting RemoteSession server\"", ")", ";", "try", "{", "remoteServer", "=", "new", "RemoteSessionServer", "(", "null", ",", "null", ",", "null", ")", ";", "}", "catch", "(", "RemoteException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "return", "remoteServer", ";", "}" ]
Start up the remote server. @param properties The properties to use on setup.
[ "Start", "up", "the", "remote", "server", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java#L77-L89
153,257
jbundle/jbundle
base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java
RemoteSessionServer.shutdown
public void shutdown() { Environment env = ((BaseApplication)m_app).getEnvironment(); if (m_app != null) m_app.free(); m_app = null; if (ClassServiceUtility.getClassService().getClassFinder(null) != null) ClassServiceUtility.getClassService().getClassFinder(null).shutdownService(null, this); if (env != null) env.freeIfDone(); //x System.exit(0); }
java
public void shutdown() { Environment env = ((BaseApplication)m_app).getEnvironment(); if (m_app != null) m_app.free(); m_app = null; if (ClassServiceUtility.getClassService().getClassFinder(null) != null) ClassServiceUtility.getClassService().getClassFinder(null).shutdownService(null, this); if (env != null) env.freeIfDone(); //x System.exit(0); }
[ "public", "void", "shutdown", "(", ")", "{", "Environment", "env", "=", "(", "(", "BaseApplication", ")", "m_app", ")", ".", "getEnvironment", "(", ")", ";", "if", "(", "m_app", "!=", "null", ")", "m_app", ".", "free", "(", ")", ";", "m_app", "=", "null", ";", "if", "(", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "getClassFinder", "(", "null", ")", "!=", "null", ")", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "getClassFinder", "(", "null", ")", ".", "shutdownService", "(", "null", ",", "this", ")", ";", "if", "(", "env", "!=", "null", ")", "env", ".", "freeIfDone", "(", ")", ";", "//x System.exit(0);", "}" ]
Shutdown the server.
[ "Shutdown", "the", "server", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/server/RemoteSessionServer.java#L174-L185
153,258
NessComputing/components-ness-lifecycle
src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java
AbstractLifecycle.addListener
@Override public void addListener(@Nonnull final LifecycleStage lifecycleStage, @Nonnull final LifecycleListener lifecycleListener) { if (!listeners.containsKey(lifecycleStage)) { throw illegalStage(lifecycleStage); } listeners.get(lifecycleStage).add(lifecycleListener); }
java
@Override public void addListener(@Nonnull final LifecycleStage lifecycleStage, @Nonnull final LifecycleListener lifecycleListener) { if (!listeners.containsKey(lifecycleStage)) { throw illegalStage(lifecycleStage); } listeners.get(lifecycleStage).add(lifecycleListener); }
[ "@", "Override", "public", "void", "addListener", "(", "@", "Nonnull", "final", "LifecycleStage", "lifecycleStage", ",", "@", "Nonnull", "final", "LifecycleListener", "lifecycleListener", ")", "{", "if", "(", "!", "listeners", ".", "containsKey", "(", "lifecycleStage", ")", ")", "{", "throw", "illegalStage", "(", "lifecycleStage", ")", ";", "}", "listeners", ".", "get", "(", "lifecycleStage", ")", ".", "add", "(", "lifecycleListener", ")", ";", "}" ]
Adds a listener to a lifecycle stage. @param lifecycleStage The Lifecycle stage on which to be notified. @param lifecycleListener Callback to be invoked when the lifecycle stage is executed.
[ "Adds", "a", "listener", "to", "a", "lifecycle", "stage", "." ]
6c8ae8ec8fdcd16b30383092ce9e70424a6760f1
https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java#L66-L73
153,259
NessComputing/components-ness-lifecycle
src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java
AbstractLifecycle.executeNext
@Override public void executeNext() { final LifecycleStage nextStage = getNextStage(); if (nextStage == null) { throw new IllegalStateException("Lifecycle already hit the final stage!"); } execute(nextStage); }
java
@Override public void executeNext() { final LifecycleStage nextStage = getNextStage(); if (nextStage == null) { throw new IllegalStateException("Lifecycle already hit the final stage!"); } execute(nextStage); }
[ "@", "Override", "public", "void", "executeNext", "(", ")", "{", "final", "LifecycleStage", "nextStage", "=", "getNextStage", "(", ")", ";", "if", "(", "nextStage", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Lifecycle already hit the final stage!\"", ")", ";", "}", "execute", "(", "nextStage", ")", ";", "}" ]
Execute the next stage in the cycle.
[ "Execute", "the", "next", "stage", "in", "the", "cycle", "." ]
6c8ae8ec8fdcd16b30383092ce9e70424a6760f1
https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java#L87-L95
153,260
NessComputing/components-ness-lifecycle
src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java
AbstractLifecycle.execute
@Override public void execute(@Nonnull final LifecycleStage lifecycleStage) { List<LifecycleListener> lifecycleListeners = listeners.get(lifecycleStage); if (lifecycleListeners == null) { throw illegalStage(lifecycleStage); } log("Stage '%s' starting...", lifecycleStage.getName()); // Reverse the order for the STOP stage, so that dependencies are torn down in reverse order. if (lifecycleStage.equals(LifecycleStage.STOP_STAGE)) { lifecycleListeners = Lists.reverse(lifecycleListeners); } for (final LifecycleListener listener : lifecycleListeners) { listener.onStage(lifecycleStage); } log("Stage '%s' complete.", lifecycleStage.getName()); }
java
@Override public void execute(@Nonnull final LifecycleStage lifecycleStage) { List<LifecycleListener> lifecycleListeners = listeners.get(lifecycleStage); if (lifecycleListeners == null) { throw illegalStage(lifecycleStage); } log("Stage '%s' starting...", lifecycleStage.getName()); // Reverse the order for the STOP stage, so that dependencies are torn down in reverse order. if (lifecycleStage.equals(LifecycleStage.STOP_STAGE)) { lifecycleListeners = Lists.reverse(lifecycleListeners); } for (final LifecycleListener listener : lifecycleListeners) { listener.onStage(lifecycleStage); } log("Stage '%s' complete.", lifecycleStage.getName()); }
[ "@", "Override", "public", "void", "execute", "(", "@", "Nonnull", "final", "LifecycleStage", "lifecycleStage", ")", "{", "List", "<", "LifecycleListener", ">", "lifecycleListeners", "=", "listeners", ".", "get", "(", "lifecycleStage", ")", ";", "if", "(", "lifecycleListeners", "==", "null", ")", "{", "throw", "illegalStage", "(", "lifecycleStage", ")", ";", "}", "log", "(", "\"Stage '%s' starting...\"", ",", "lifecycleStage", ".", "getName", "(", ")", ")", ";", "// Reverse the order for the STOP stage, so that dependencies are torn down in reverse order.", "if", "(", "lifecycleStage", ".", "equals", "(", "LifecycleStage", ".", "STOP_STAGE", ")", ")", "{", "lifecycleListeners", "=", "Lists", ".", "reverse", "(", "lifecycleListeners", ")", ";", "}", "for", "(", "final", "LifecycleListener", "listener", ":", "lifecycleListeners", ")", "{", "listener", ".", "onStage", "(", "lifecycleStage", ")", ";", "}", "log", "(", "\"Stage '%s' complete.\"", ",", "lifecycleStage", ".", "getName", "(", ")", ")", ";", "}" ]
Execute a lifecycle stage.
[ "Execute", "a", "lifecycle", "stage", "." ]
6c8ae8ec8fdcd16b30383092ce9e70424a6760f1
https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java#L123-L143
153,261
NessComputing/components-ness-lifecycle
src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java
AbstractLifecycle.join
protected void join(@Nonnull final LifecycleStage lifecycleStage, final boolean cycle) throws InterruptedException { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (cycle) { AbstractLifecycle.this.executeTo(lifecycleStage); } else { AbstractLifecycle.this.execute(lifecycleStage); } } }); Thread.currentThread().join(); }
java
protected void join(@Nonnull final LifecycleStage lifecycleStage, final boolean cycle) throws InterruptedException { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (cycle) { AbstractLifecycle.this.executeTo(lifecycleStage); } else { AbstractLifecycle.this.execute(lifecycleStage); } } }); Thread.currentThread().join(); }
[ "protected", "void", "join", "(", "@", "Nonnull", "final", "LifecycleStage", "lifecycleStage", ",", "final", "boolean", "cycle", ")", "throws", "InterruptedException", "{", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "cycle", ")", "{", "AbstractLifecycle", ".", "this", ".", "executeTo", "(", "lifecycleStage", ")", ";", "}", "else", "{", "AbstractLifecycle", ".", "this", ".", "execute", "(", "lifecycleStage", ")", ";", "}", "}", "}", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "join", "(", ")", ";", "}" ]
Register a shutdown hook to execute the given stage on JVM shutdown, and join against the current thread. This will block, so there needs to be a another way to shut the current thread down. @param lifecycleStage The stage to reach. @param cycle If true, then cycle to the stage, otherwise, just execute the stage. @throws InterruptedException if the Thread.currentThread.join() is interrupted
[ "Register", "a", "shutdown", "hook", "to", "execute", "the", "given", "stage", "on", "JVM", "shutdown", "and", "join", "against", "the", "current", "thread", ".", "This", "will", "block", "so", "there", "needs", "to", "be", "a", "another", "way", "to", "shut", "the", "current", "thread", "down", "." ]
6c8ae8ec8fdcd16b30383092ce9e70424a6760f1
https://github.com/NessComputing/components-ness-lifecycle/blob/6c8ae8ec8fdcd16b30383092ce9e70424a6760f1/src/main/java/com/nesscomputing/lifecycle/AbstractLifecycle.java#L155-L170
153,262
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.setArguments
public void setArguments(Object... arguments) { Params.notNullOrEmpty(arguments, "Arguments"); this.arguments = arguments; argumentsWriter = ClientEncoders.getInstance().getArgumentsWriter(arguments); }
java
public void setArguments(Object... arguments) { Params.notNullOrEmpty(arguments, "Arguments"); this.arguments = arguments; argumentsWriter = ClientEncoders.getInstance().getArgumentsWriter(arguments); }
[ "public", "void", "setArguments", "(", "Object", "...", "arguments", ")", "{", "Params", ".", "notNullOrEmpty", "(", "arguments", ",", "\"Arguments\"", ")", ";", "this", ".", "arguments", "=", "arguments", ";", "argumentsWriter", "=", "ClientEncoders", ".", "getInstance", "(", ")", ".", "getArgumentsWriter", "(", "arguments", ")", ";", "}" ]
Set remote method invocation actual parameters. Parameters order and types should be consistent with remote method signature. @param arguments variable number of actual arguments for remote method invocation. @throws IllegalArgumentException if given arguments is null or missing.
[ "Set", "remote", "method", "invocation", "actual", "parameters", ".", "Parameters", "order", "and", "types", "should", "be", "consistent", "with", "remote", "method", "signature", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L254-L258
153,263
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.setExceptions
public void setExceptions(Class<?>[] exceptions) { for (Class<?> exception : exceptions) { // uses simple name because exception may be declared into .client package this.exceptions.add(exception.getSimpleName()); } }
java
public void setExceptions(Class<?>[] exceptions) { for (Class<?> exception : exceptions) { // uses simple name because exception may be declared into .client package this.exceptions.add(exception.getSimpleName()); } }
[ "public", "void", "setExceptions", "(", "Class", "<", "?", ">", "[", "]", "exceptions", ")", "{", "for", "(", "Class", "<", "?", ">", "exception", ":", "exceptions", ")", "{", "// uses simple name because exception may be declared into .client package\r", "this", ".", "exceptions", ".", "add", "(", "exception", ".", "getSimpleName", "(", ")", ")", ";", "}", "}" ]
Set method exceptions list. This exceptions list is used by the logic that handle remote exception. It should be consistent with remote method signature. @param exceptions method exceptions list.
[ "Set", "method", "exceptions", "list", ".", "This", "exceptions", "list", "is", "used", "by", "the", "logic", "that", "handle", "remote", "exception", ".", "It", "should", "be", "consistent", "with", "remote", "method", "signature", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L278-L283
153,264
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.exec
private Object exec() throws Exception { boolean exception = false; try { return exec(connection); } catch (Throwable t) { log.dump(String.format("Error processing HTTP-RMI |%s|.", connection.getURL()), t); exception = true; throw t; } finally { if (exception || CONNECTION_CLOSE.equals(connection.getHeaderField("Connection"))) { connection.disconnect(); } } }
java
private Object exec() throws Exception { boolean exception = false; try { return exec(connection); } catch (Throwable t) { log.dump(String.format("Error processing HTTP-RMI |%s|.", connection.getURL()), t); exception = true; throw t; } finally { if (exception || CONNECTION_CLOSE.equals(connection.getHeaderField("Connection"))) { connection.disconnect(); } } }
[ "private", "Object", "exec", "(", ")", "throws", "Exception", "{", "boolean", "exception", "=", "false", ";", "try", "{", "return", "exec", "(", "connection", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "log", ".", "dump", "(", "String", ".", "format", "(", "\"Error processing HTTP-RMI |%s|.\"", ",", "connection", ".", "getURL", "(", ")", ")", ",", "t", ")", ";", "exception", "=", "true", ";", "throw", "t", ";", "}", "finally", "{", "if", "(", "exception", "||", "CONNECTION_CLOSE", ".", "equals", "(", "connection", ".", "getHeaderField", "(", "\"Connection\"", ")", ")", ")", "{", "connection", ".", "disconnect", "(", ")", ";", "}", "}", "}" ]
Executes transaction and returns remote value. Takes care to disconnect connection if server response has close header; also disconnect on any kind of error. @return remote value. @throws Exception any exception on transaction processing is bubbled up to caller.
[ "Executes", "transaction", "and", "returns", "remote", "value", ".", "Takes", "care", "to", "disconnect", "connection", "if", "server", "response", "has", "close", "header", ";", "also", "disconnect", "on", "any", "kind", "of", "error", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L375-L388
153,265
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.exec
private Object exec(HttpURLConnection connection) throws Exception { connection.setConnectTimeout(connectionTimeout); connection.setReadTimeout(readTimeout); connection.setRequestMethod(arguments == null ? "GET" : "POST"); connection.setRequestProperty("User-Agent", "j(s)-lib/1.9.3"); connection.setRequestProperty("Accept", "application/json, text/xml, application/octet-stream"); connection.setRequestProperty("Pragma", "no-cache"); connection.setRequestProperty("Cache", "no-cache"); // do not set connection close request header in order to let HttpUrlConnection to transparently process persistent // connections, if server request so // note that on HTTP 1.1 all connections are considered persistent unless explicitly declared otherwise // anyway, if js.net.client.android system property is defined, force connection close if (System.getProperty("js.net.client.android") != null) { connection.setRequestProperty("Connection", "close"); } if (headers != null) { for (Map.Entry<String, String> entry : headers.entrySet()) { connection.setRequestProperty(entry.getKey(), entry.getValue()); } } String sessionCookie = sessionCookies.get(connection.getURL()); if (sessionCookie != null) { connection.setRequestProperty("Cookie", sessionCookie); } if (arguments != null) { connection.setDoOutput(true); String contentType = argumentsWriter.getContentType(); if (contentType != null) { connection.setRequestProperty("Content-Type", contentType); } argumentsWriter.write(connection.getOutputStream(), arguments); } // at this point connection implementation perform the actual HTTP transaction: send request and wait for response, // parse response status code and headers and prepare a stream on response body int statusCode = connection.getResponseCode(); // current RMI transaction implementation accept as success only 200 or 204 for void remote method if (statusCode != SC_OK && statusCode != SC_NO_CONTENT) { onError(statusCode); // error handler throws exception on any status code } String cookies = connection.getHeaderField("Set-Cookie"); if (cookies != null) { Matcher matcher = JSESSIONID_PATTERN.matcher(cookies); if (matcher.find()) { sessionCookies.put(connection.getURL(), matcher.group(1)); } } if (Types.isVoid(returnType)) { return null; } if (!Types.isVoid(returnType) && connection.getContentLength() == 0) { throw new BugError("Invalid HTTP-RMI transaction with |%s|. Expect return value of type |%s| but got empty response.", connection.getURL(), returnType); } ValueReader valueReader = ClientEncoders.getInstance().getValueReader(connection); try { return valueReader.read(connection.getInputStream(), returnType); } catch (IOException e) { throw new BugError("Invalid HTTP-RMI transaction with |%s|. Response cannot be parsed to type |%s|. Cause: %s", connection.getURL(), returnType, e); } }
java
private Object exec(HttpURLConnection connection) throws Exception { connection.setConnectTimeout(connectionTimeout); connection.setReadTimeout(readTimeout); connection.setRequestMethod(arguments == null ? "GET" : "POST"); connection.setRequestProperty("User-Agent", "j(s)-lib/1.9.3"); connection.setRequestProperty("Accept", "application/json, text/xml, application/octet-stream"); connection.setRequestProperty("Pragma", "no-cache"); connection.setRequestProperty("Cache", "no-cache"); // do not set connection close request header in order to let HttpUrlConnection to transparently process persistent // connections, if server request so // note that on HTTP 1.1 all connections are considered persistent unless explicitly declared otherwise // anyway, if js.net.client.android system property is defined, force connection close if (System.getProperty("js.net.client.android") != null) { connection.setRequestProperty("Connection", "close"); } if (headers != null) { for (Map.Entry<String, String> entry : headers.entrySet()) { connection.setRequestProperty(entry.getKey(), entry.getValue()); } } String sessionCookie = sessionCookies.get(connection.getURL()); if (sessionCookie != null) { connection.setRequestProperty("Cookie", sessionCookie); } if (arguments != null) { connection.setDoOutput(true); String contentType = argumentsWriter.getContentType(); if (contentType != null) { connection.setRequestProperty("Content-Type", contentType); } argumentsWriter.write(connection.getOutputStream(), arguments); } // at this point connection implementation perform the actual HTTP transaction: send request and wait for response, // parse response status code and headers and prepare a stream on response body int statusCode = connection.getResponseCode(); // current RMI transaction implementation accept as success only 200 or 204 for void remote method if (statusCode != SC_OK && statusCode != SC_NO_CONTENT) { onError(statusCode); // error handler throws exception on any status code } String cookies = connection.getHeaderField("Set-Cookie"); if (cookies != null) { Matcher matcher = JSESSIONID_PATTERN.matcher(cookies); if (matcher.find()) { sessionCookies.put(connection.getURL(), matcher.group(1)); } } if (Types.isVoid(returnType)) { return null; } if (!Types.isVoid(returnType) && connection.getContentLength() == 0) { throw new BugError("Invalid HTTP-RMI transaction with |%s|. Expect return value of type |%s| but got empty response.", connection.getURL(), returnType); } ValueReader valueReader = ClientEncoders.getInstance().getValueReader(connection); try { return valueReader.read(connection.getInputStream(), returnType); } catch (IOException e) { throw new BugError("Invalid HTTP-RMI transaction with |%s|. Response cannot be parsed to type |%s|. Cause: %s", connection.getURL(), returnType, e); } }
[ "private", "Object", "exec", "(", "HttpURLConnection", "connection", ")", "throws", "Exception", "{", "connection", ".", "setConnectTimeout", "(", "connectionTimeout", ")", ";", "connection", ".", "setReadTimeout", "(", "readTimeout", ")", ";", "connection", ".", "setRequestMethod", "(", "arguments", "==", "null", "?", "\"GET\"", ":", "\"POST\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"User-Agent\"", ",", "\"j(s)-lib/1.9.3\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Accept\"", ",", "\"application/json, text/xml, application/octet-stream\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Pragma\"", ",", "\"no-cache\"", ")", ";", "connection", ".", "setRequestProperty", "(", "\"Cache\"", ",", "\"no-cache\"", ")", ";", "// do not set connection close request header in order to let HttpUrlConnection to transparently process persistent\r", "// connections, if server request so\r", "// note that on HTTP 1.1 all connections are considered persistent unless explicitly declared otherwise\r", "// anyway, if js.net.client.android system property is defined, force connection close\r", "if", "(", "System", ".", "getProperty", "(", "\"js.net.client.android\"", ")", "!=", "null", ")", "{", "connection", ".", "setRequestProperty", "(", "\"Connection\"", ",", "\"close\"", ")", ";", "}", "if", "(", "headers", "!=", "null", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "headers", ".", "entrySet", "(", ")", ")", "{", "connection", ".", "setRequestProperty", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "String", "sessionCookie", "=", "sessionCookies", ".", "get", "(", "connection", ".", "getURL", "(", ")", ")", ";", "if", "(", "sessionCookie", "!=", "null", ")", "{", "connection", ".", "setRequestProperty", "(", "\"Cookie\"", ",", "sessionCookie", ")", ";", "}", "if", "(", "arguments", "!=", "null", ")", "{", "connection", ".", "setDoOutput", "(", "true", ")", ";", "String", "contentType", "=", "argumentsWriter", ".", "getContentType", "(", ")", ";", "if", "(", "contentType", "!=", "null", ")", "{", "connection", ".", "setRequestProperty", "(", "\"Content-Type\"", ",", "contentType", ")", ";", "}", "argumentsWriter", ".", "write", "(", "connection", ".", "getOutputStream", "(", ")", ",", "arguments", ")", ";", "}", "// at this point connection implementation perform the actual HTTP transaction: send request and wait for response,\r", "// parse response status code and headers and prepare a stream on response body\r", "int", "statusCode", "=", "connection", ".", "getResponseCode", "(", ")", ";", "// current RMI transaction implementation accept as success only 200 or 204 for void remote method\r", "if", "(", "statusCode", "!=", "SC_OK", "&&", "statusCode", "!=", "SC_NO_CONTENT", ")", "{", "onError", "(", "statusCode", ")", ";", "// error handler throws exception on any status code\r", "}", "String", "cookies", "=", "connection", ".", "getHeaderField", "(", "\"Set-Cookie\"", ")", ";", "if", "(", "cookies", "!=", "null", ")", "{", "Matcher", "matcher", "=", "JSESSIONID_PATTERN", ".", "matcher", "(", "cookies", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "sessionCookies", ".", "put", "(", "connection", ".", "getURL", "(", ")", ",", "matcher", ".", "group", "(", "1", ")", ")", ";", "}", "}", "if", "(", "Types", ".", "isVoid", "(", "returnType", ")", ")", "{", "return", "null", ";", "}", "if", "(", "!", "Types", ".", "isVoid", "(", "returnType", ")", "&&", "connection", ".", "getContentLength", "(", ")", "==", "0", ")", "{", "throw", "new", "BugError", "(", "\"Invalid HTTP-RMI transaction with |%s|. Expect return value of type |%s| but got empty response.\"", ",", "connection", ".", "getURL", "(", ")", ",", "returnType", ")", ";", "}", "ValueReader", "valueReader", "=", "ClientEncoders", ".", "getInstance", "(", ")", ".", "getValueReader", "(", "connection", ")", ";", "try", "{", "return", "valueReader", ".", "read", "(", "connection", ".", "getInputStream", "(", ")", ",", "returnType", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BugError", "(", "\"Invalid HTTP-RMI transaction with |%s|. Response cannot be parsed to type |%s|. Cause: %s\"", ",", "connection", ".", "getURL", "(", ")", ",", "returnType", ",", "e", ")", ";", "}", "}" ]
Execute synchronous remote method invocation using given HTTP connection. @param connection HTTP connection to remote method. @return remote method return value. @throws Exception if transaction fails for any reasons be it client local, networking or remote process.
[ "Execute", "synchronous", "remote", "method", "invocation", "using", "given", "HTTP", "connection", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L397-L467
153,266
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.onError
private void onError(int statusCode) throws Exception { // if status code is [200 300) range response body is accessible via getInputStream // otherwise getErrorStream should be used // trying to use getInputStream for status codes not in [200 300) range will rise IOException switch (statusCode) { case SC_FORBIDDEN: // server understood the request but refuses to fulfill it // compared with SC_UNAUTHORIZED, sending authentication will not grant access // common SC_FORBIDDEN condition may be Tomcat filtering by remote address and client IP is not allowed throw new RmiException("Server refuses to process request |%s|. Common cause may be Tomcat filtering by remote address and this IP is not allowed.", connection.getURL()); case SC_UNAUTHORIZED: throw new RmiException("Attempt to access private remote method |%s| without authorization.", connection.getURL()); case SC_NOT_FOUND: // not found may occur if front end Apache HTTP server does not recognize the protocol, e.g. trying to access // securely a // public method or because of misspelled extension; also virtual host configuration for remote context may be wrong throw new RmiException("Method |%s| not found. Check URL spelling, protocol unmatched or unrecognized extension.", connection.getURL()); case SC_SERVICE_UNAVAILABLE: // front end HTTP server is running but application server is down; front end server responds with 503 throw new RmiException("Front-end HTTP server is up but back-end is down. HTTP-RMI transaction |%s| aborted.", connection.getURL()); case SC_BAD_REQUEST: if (isJSON(connection.getContentType())) { // business constrain not satisfied throw (BusinessException) readJsonObject(connection.getErrorStream(), BusinessException.class); } break; case SC_INTERNAL_SERVER_ERROR: if (isJSON(connection.getContentType())) { RemoteException remoteException = (RemoteException) readJsonObject(connection.getErrorStream(), RemoteException.class); log.error("HTTP-RMI error on |%s|: %s", connection.getURL(), remoteException); // if remote exception is an exception declared by method signature we throw it in this virtual machine if (exceptions.contains(getRemoteExceptionCause(remoteException))) { Class<? extends Throwable> cause = Classes.forOptionalName(remoteException.getCause()); if (cause != null) { String message = remoteException.getMessage(); if (message == null) { throw (Exception) Classes.newInstance(cause); } throw (Exception) Classes.newInstance(cause, remoteException.getMessage()); } } // if received remote exception is not listed by method signature replace it with RmiException throw new RmiException(connection.getURL(), remoteException); } } final InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String responseDump = Strings.load(errorStream, 100); log.error("HTTP-RMI error on |%s|. Server returned |%d|. Response dump:\r\n\t%s", connection.getURL(), statusCode, responseDump); } else { log.error("HTTP-RMI error on |%s|. Server returned |%d|.", connection.getURL(), statusCode); } throw new RmiException("HTTP-RMI error on |%s|. Server returned |%d|.", connection.getURL(), statusCode); }
java
private void onError(int statusCode) throws Exception { // if status code is [200 300) range response body is accessible via getInputStream // otherwise getErrorStream should be used // trying to use getInputStream for status codes not in [200 300) range will rise IOException switch (statusCode) { case SC_FORBIDDEN: // server understood the request but refuses to fulfill it // compared with SC_UNAUTHORIZED, sending authentication will not grant access // common SC_FORBIDDEN condition may be Tomcat filtering by remote address and client IP is not allowed throw new RmiException("Server refuses to process request |%s|. Common cause may be Tomcat filtering by remote address and this IP is not allowed.", connection.getURL()); case SC_UNAUTHORIZED: throw new RmiException("Attempt to access private remote method |%s| without authorization.", connection.getURL()); case SC_NOT_FOUND: // not found may occur if front end Apache HTTP server does not recognize the protocol, e.g. trying to access // securely a // public method or because of misspelled extension; also virtual host configuration for remote context may be wrong throw new RmiException("Method |%s| not found. Check URL spelling, protocol unmatched or unrecognized extension.", connection.getURL()); case SC_SERVICE_UNAVAILABLE: // front end HTTP server is running but application server is down; front end server responds with 503 throw new RmiException("Front-end HTTP server is up but back-end is down. HTTP-RMI transaction |%s| aborted.", connection.getURL()); case SC_BAD_REQUEST: if (isJSON(connection.getContentType())) { // business constrain not satisfied throw (BusinessException) readJsonObject(connection.getErrorStream(), BusinessException.class); } break; case SC_INTERNAL_SERVER_ERROR: if (isJSON(connection.getContentType())) { RemoteException remoteException = (RemoteException) readJsonObject(connection.getErrorStream(), RemoteException.class); log.error("HTTP-RMI error on |%s|: %s", connection.getURL(), remoteException); // if remote exception is an exception declared by method signature we throw it in this virtual machine if (exceptions.contains(getRemoteExceptionCause(remoteException))) { Class<? extends Throwable> cause = Classes.forOptionalName(remoteException.getCause()); if (cause != null) { String message = remoteException.getMessage(); if (message == null) { throw (Exception) Classes.newInstance(cause); } throw (Exception) Classes.newInstance(cause, remoteException.getMessage()); } } // if received remote exception is not listed by method signature replace it with RmiException throw new RmiException(connection.getURL(), remoteException); } } final InputStream errorStream = connection.getErrorStream(); if (errorStream != null) { String responseDump = Strings.load(errorStream, 100); log.error("HTTP-RMI error on |%s|. Server returned |%d|. Response dump:\r\n\t%s", connection.getURL(), statusCode, responseDump); } else { log.error("HTTP-RMI error on |%s|. Server returned |%d|.", connection.getURL(), statusCode); } throw new RmiException("HTTP-RMI error on |%s|. Server returned |%d|.", connection.getURL(), statusCode); }
[ "private", "void", "onError", "(", "int", "statusCode", ")", "throws", "Exception", "{", "// if status code is [200 300) range response body is accessible via getInputStream\r", "// otherwise getErrorStream should be used\r", "// trying to use getInputStream for status codes not in [200 300) range will rise IOException\r", "switch", "(", "statusCode", ")", "{", "case", "SC_FORBIDDEN", ":", "// server understood the request but refuses to fulfill it\r", "// compared with SC_UNAUTHORIZED, sending authentication will not grant access\r", "// common SC_FORBIDDEN condition may be Tomcat filtering by remote address and client IP is not allowed\r", "throw", "new", "RmiException", "(", "\"Server refuses to process request |%s|. Common cause may be Tomcat filtering by remote address and this IP is not allowed.\"", ",", "connection", ".", "getURL", "(", ")", ")", ";", "case", "SC_UNAUTHORIZED", ":", "throw", "new", "RmiException", "(", "\"Attempt to access private remote method |%s| without authorization.\"", ",", "connection", ".", "getURL", "(", ")", ")", ";", "case", "SC_NOT_FOUND", ":", "// not found may occur if front end Apache HTTP server does not recognize the protocol, e.g. trying to access\r", "// securely a\r", "// public method or because of misspelled extension; also virtual host configuration for remote context may be wrong\r", "throw", "new", "RmiException", "(", "\"Method |%s| not found. Check URL spelling, protocol unmatched or unrecognized extension.\"", ",", "connection", ".", "getURL", "(", ")", ")", ";", "case", "SC_SERVICE_UNAVAILABLE", ":", "// front end HTTP server is running but application server is down; front end server responds with 503\r", "throw", "new", "RmiException", "(", "\"Front-end HTTP server is up but back-end is down. HTTP-RMI transaction |%s| aborted.\"", ",", "connection", ".", "getURL", "(", ")", ")", ";", "case", "SC_BAD_REQUEST", ":", "if", "(", "isJSON", "(", "connection", ".", "getContentType", "(", ")", ")", ")", "{", "// business constrain not satisfied\r", "throw", "(", "BusinessException", ")", "readJsonObject", "(", "connection", ".", "getErrorStream", "(", ")", ",", "BusinessException", ".", "class", ")", ";", "}", "break", ";", "case", "SC_INTERNAL_SERVER_ERROR", ":", "if", "(", "isJSON", "(", "connection", ".", "getContentType", "(", ")", ")", ")", "{", "RemoteException", "remoteException", "=", "(", "RemoteException", ")", "readJsonObject", "(", "connection", ".", "getErrorStream", "(", ")", ",", "RemoteException", ".", "class", ")", ";", "log", ".", "error", "(", "\"HTTP-RMI error on |%s|: %s\"", ",", "connection", ".", "getURL", "(", ")", ",", "remoteException", ")", ";", "// if remote exception is an exception declared by method signature we throw it in this virtual machine\r", "if", "(", "exceptions", ".", "contains", "(", "getRemoteExceptionCause", "(", "remoteException", ")", ")", ")", "{", "Class", "<", "?", "extends", "Throwable", ">", "cause", "=", "Classes", ".", "forOptionalName", "(", "remoteException", ".", "getCause", "(", ")", ")", ";", "if", "(", "cause", "!=", "null", ")", "{", "String", "message", "=", "remoteException", ".", "getMessage", "(", ")", ";", "if", "(", "message", "==", "null", ")", "{", "throw", "(", "Exception", ")", "Classes", ".", "newInstance", "(", "cause", ")", ";", "}", "throw", "(", "Exception", ")", "Classes", ".", "newInstance", "(", "cause", ",", "remoteException", ".", "getMessage", "(", ")", ")", ";", "}", "}", "// if received remote exception is not listed by method signature replace it with RmiException\r", "throw", "new", "RmiException", "(", "connection", ".", "getURL", "(", ")", ",", "remoteException", ")", ";", "}", "}", "final", "InputStream", "errorStream", "=", "connection", ".", "getErrorStream", "(", ")", ";", "if", "(", "errorStream", "!=", "null", ")", "{", "String", "responseDump", "=", "Strings", ".", "load", "(", "errorStream", ",", "100", ")", ";", "log", ".", "error", "(", "\"HTTP-RMI error on |%s|. Server returned |%d|. Response dump:\\r\\n\\t%s\"", ",", "connection", ".", "getURL", "(", ")", ",", "statusCode", ",", "responseDump", ")", ";", "}", "else", "{", "log", ".", "error", "(", "\"HTTP-RMI error on |%s|. Server returned |%d|.\"", ",", "connection", ".", "getURL", "(", ")", ",", "statusCode", ")", ";", "}", "throw", "new", "RmiException", "(", "\"HTTP-RMI error on |%s|. Server returned |%d|.\"", ",", "connection", ".", "getURL", "(", ")", ",", "statusCode", ")", ";", "}" ]
Handle transaction error. @param statusCode HTTP response status code. @throws IOException if reading connection error stream fails. @throws RmiException for all error codes less business exception and internal server error. @throws BusinessException if server side logic detects that a business constrain is broken. @throws Exception internal server error is due to a checked exception present into remote method signature.
[ "Handle", "transaction", "error", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L478-L540
153,267
js-lib-com/net-client
src/main/java/js/net/client/HttpRmiTransaction.java
HttpRmiTransaction.readJsonObject
private static Object readJsonObject(InputStream stream, Type type) throws IOException { BufferedReader reader = null; Json json = Classes.loadService(Json.class); try { reader = Files.createBufferedReader(stream); return json.parse(reader, type); } finally { // do not use Files.close because we want to throw IOException is reader close fails if (reader != null) { reader.close(); } } }
java
private static Object readJsonObject(InputStream stream, Type type) throws IOException { BufferedReader reader = null; Json json = Classes.loadService(Json.class); try { reader = Files.createBufferedReader(stream); return json.parse(reader, type); } finally { // do not use Files.close because we want to throw IOException is reader close fails if (reader != null) { reader.close(); } } }
[ "private", "static", "Object", "readJsonObject", "(", "InputStream", "stream", ",", "Type", "type", ")", "throws", "IOException", "{", "BufferedReader", "reader", "=", "null", ";", "Json", "json", "=", "Classes", ".", "loadService", "(", "Json", ".", "class", ")", ";", "try", "{", "reader", "=", "Files", ".", "createBufferedReader", "(", "stream", ")", ";", "return", "json", ".", "parse", "(", "reader", ",", "type", ")", ";", "}", "finally", "{", "// do not use Files.close because we want to throw IOException is reader close fails\r", "if", "(", "reader", "!=", "null", ")", "{", "reader", ".", "close", "(", ")", ";", "}", "}", "}" ]
Read JSON object from input stream and return initialized object instance. @param stream input stream, @param type expected type. @return object instance of requested type. @throws IOException if stream reading or JSON parsing fails.
[ "Read", "JSON", "object", "from", "input", "stream", "and", "return", "initialized", "object", "instance", "." ]
0489f85d8baa1be1ff115aa79929e0cf05d4c72d
https://github.com/js-lib-com/net-client/blob/0489f85d8baa1be1ff115aa79929e0cf05d4c72d/src/main/java/js/net/client/HttpRmiTransaction.java#L564-L576
153,268
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java
PropertyCollection.loadProperties
public void loadProperties(String prefix) { List<Property> props = null; try { props = getListByPrefix(prefix); } catch (Exception e) { log.error("Error retrieving properties with prefix: " + prefix, e); return; } for (Property prop : props) { if (prop.getName() != null) { this.properties.put(prop.getName(), prop); } } }
java
public void loadProperties(String prefix) { List<Property> props = null; try { props = getListByPrefix(prefix); } catch (Exception e) { log.error("Error retrieving properties with prefix: " + prefix, e); return; } for (Property prop : props) { if (prop.getName() != null) { this.properties.put(prop.getName(), prop); } } }
[ "public", "void", "loadProperties", "(", "String", "prefix", ")", "{", "List", "<", "Property", ">", "props", "=", "null", ";", "try", "{", "props", "=", "getListByPrefix", "(", "prefix", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Error retrieving properties with prefix: \"", "+", "prefix", ",", "e", ")", ";", "return", ";", "}", "for", "(", "Property", "prop", ":", "props", ")", "{", "if", "(", "prop", ".", "getName", "(", ")", "!=", "null", ")", "{", "this", ".", "properties", ".", "put", "(", "prop", ".", "getName", "(", ")", ",", "prop", ")", ";", "}", "}", "}" ]
Loads all property objects beginning with the specified prefix. The property objects are stored in a map indexed by the property name for easy retrieval. @param prefix The property prefix.
[ "Loads", "all", "property", "objects", "beginning", "with", "the", "specified", "prefix", ".", "The", "property", "objects", "are", "stored", "in", "a", "map", "indexed", "by", "the", "property", "name", "for", "easy", "retrieval", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java#L71-L86
153,269
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java
PropertyCollection.getValue
public int getValue(String name, String[] choices) { String val = getValue(name, ""); int index = Arrays.asList(choices).indexOf(val); return index == -1 ? 0 : index; }
java
public int getValue(String name, String[] choices) { String val = getValue(name, ""); int index = Arrays.asList(choices).indexOf(val); return index == -1 ? 0 : index; }
[ "public", "int", "getValue", "(", "String", "name", ",", "String", "[", "]", "choices", ")", "{", "String", "val", "=", "getValue", "(", "name", ",", "\"\"", ")", ";", "int", "index", "=", "Arrays", ".", "asList", "(", "choices", ")", ".", "indexOf", "(", "val", ")", ";", "return", "index", "==", "-", "1", "?", "0", ":", "index", ";", "}" ]
Returns the index of a property value as it occurs in the choice list. @param name Property name. @param choices Array of possible choice values. The first entry is assumed to be the default. @return Index of the property value in the choices array. Returns 0 if not found.
[ "Returns", "the", "index", "of", "a", "property", "value", "as", "it", "occurs", "in", "the", "choice", "list", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java#L133-L137
153,270
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java
PropertyCollection.getValue
public boolean getValue(String name, boolean dflt) { try { String val = getValue(name, Boolean.toString(dflt)).toLowerCase(); return val.startsWith("y") ? true : Boolean.parseBoolean(val); } catch (Exception e) { return false; } }
java
public boolean getValue(String name, boolean dflt) { try { String val = getValue(name, Boolean.toString(dflt)).toLowerCase(); return val.startsWith("y") ? true : Boolean.parseBoolean(val); } catch (Exception e) { return false; } }
[ "public", "boolean", "getValue", "(", "String", "name", ",", "boolean", "dflt", ")", "{", "try", "{", "String", "val", "=", "getValue", "(", "name", ",", "Boolean", ".", "toString", "(", "dflt", ")", ")", ".", "toLowerCase", "(", ")", ";", "return", "val", ".", "startsWith", "(", "\"y\"", ")", "?", "true", ":", "Boolean", ".", "parseBoolean", "(", "val", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "}" ]
Returns a boolean property value. @param name Property name. @param dflt Default value if a property value is not found. @return Property value or default value if property value not found.
[ "Returns", "a", "boolean", "property", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java#L146-L153
153,271
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java
PropertyCollection.getValue
public int getValue(String name, int dflt) { try { return Integer.parseInt(getValue(name, Integer.toString(dflt))); } catch (Exception e) { return dflt; } }
java
public int getValue(String name, int dflt) { try { return Integer.parseInt(getValue(name, Integer.toString(dflt))); } catch (Exception e) { return dflt; } }
[ "public", "int", "getValue", "(", "String", "name", ",", "int", "dflt", ")", "{", "try", "{", "return", "Integer", ".", "parseInt", "(", "getValue", "(", "name", ",", "Integer", ".", "toString", "(", "dflt", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "dflt", ";", "}", "}" ]
Returns an integer property value. @param name Property name. @param dflt Default value if a property value is not found. @return Property value or default value if property value not found.
[ "Returns", "an", "integer", "property", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java#L162-L168
153,272
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java
PropertyCollection.getValue
public String getValue(String name, String dflt) { Property prop = getProperty(name); return prop == null ? dflt : prop.getValue(); }
java
public String getValue(String name, String dflt) { Property prop = getProperty(name); return prop == null ? dflt : prop.getValue(); }
[ "public", "String", "getValue", "(", "String", "name", ",", "String", "dflt", ")", "{", "Property", "prop", "=", "getProperty", "(", "name", ")", ";", "return", "prop", "==", "null", "?", "dflt", ":", "prop", ".", "getValue", "(", ")", ";", "}" ]
Returns a string property value. @param name Property name. @param dflt Default value if a property value is not found. @return Property value or default value if property value not found.
[ "Returns", "a", "string", "property", "value", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/property/PropertyCollection.java#L177-L180
153,273
jbundle/jbundle
base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XScreenField.java
XScreenField.printInputControl
public void printInputControl(PrintWriter out, String strFieldDesc, String strFieldName, String strSize, String strMaxSize, String strValue, String strControlType, String strFieldType) { out.println(" <xfm:" + strControlType + " xform=\"form1\" ref=\"" + strFieldName + "\" cols=\"" + strSize + "\" type=\"" + strFieldType + "\">"); out.println(" <xfm:caption>" + strFieldDesc + "</xfm:caption>"); out.println(" </xfm:" + strControlType + ">"); }
java
public void printInputControl(PrintWriter out, String strFieldDesc, String strFieldName, String strSize, String strMaxSize, String strValue, String strControlType, String strFieldType) { out.println(" <xfm:" + strControlType + " xform=\"form1\" ref=\"" + strFieldName + "\" cols=\"" + strSize + "\" type=\"" + strFieldType + "\">"); out.println(" <xfm:caption>" + strFieldDesc + "</xfm:caption>"); out.println(" </xfm:" + strControlType + ">"); }
[ "public", "void", "printInputControl", "(", "PrintWriter", "out", ",", "String", "strFieldDesc", ",", "String", "strFieldName", ",", "String", "strSize", ",", "String", "strMaxSize", ",", "String", "strValue", ",", "String", "strControlType", ",", "String", "strFieldType", ")", "{", "out", ".", "println", "(", "\" <xfm:\"", "+", "strControlType", "+", "\" xform=\\\"form1\\\" ref=\\\"\"", "+", "strFieldName", "+", "\"\\\" cols=\\\"\"", "+", "strSize", "+", "\"\\\" type=\\\"\"", "+", "strFieldType", "+", "\"\\\">\"", ")", ";", "out", ".", "println", "(", "\" <xfm:caption>\"", "+", "strFieldDesc", "+", "\"</xfm:caption>\"", ")", ";", "out", ".", "println", "(", "\" </xfm:\"", "+", "strControlType", "+", "\">\"", ")", ";", "}" ]
Display this field in XML input format. @param strFieldType The field type
[ "Display", "this", "field", "in", "XML", "input", "format", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XScreenField.java#L147-L152
153,274
isisaddons-legacy/isis-module-publishing
dom/src/main/java/org/isisaddons/module/publishing/dom/eventserializer/RestfulObjectsSpecEventSerializer.java
RestfulObjectsSpecEventSerializer.asEventRepr
JsonRepresentation asEventRepr(EventMetadata metadata, final JsonRepresentation payloadRepr) { final JsonRepresentation eventRepr = JsonRepresentation.newMap(); final JsonRepresentation metadataRepr = JsonRepresentation.newMap(); eventRepr.mapPut("metadata", metadataRepr); metadataRepr.mapPut("id", metadata.getId()); metadataRepr.mapPut("transactionId", metadata.getTransactionId()); metadataRepr.mapPut("sequence", metadata.getSequence()); metadataRepr.mapPut("eventType", metadata.getEventType()); metadataRepr.mapPut("user", metadata.getUser()); metadataRepr.mapPut("timestamp", metadata.getTimestamp()); eventRepr.mapPut("payload", payloadRepr); return eventRepr; }
java
JsonRepresentation asEventRepr(EventMetadata metadata, final JsonRepresentation payloadRepr) { final JsonRepresentation eventRepr = JsonRepresentation.newMap(); final JsonRepresentation metadataRepr = JsonRepresentation.newMap(); eventRepr.mapPut("metadata", metadataRepr); metadataRepr.mapPut("id", metadata.getId()); metadataRepr.mapPut("transactionId", metadata.getTransactionId()); metadataRepr.mapPut("sequence", metadata.getSequence()); metadataRepr.mapPut("eventType", metadata.getEventType()); metadataRepr.mapPut("user", metadata.getUser()); metadataRepr.mapPut("timestamp", metadata.getTimestamp()); eventRepr.mapPut("payload", payloadRepr); return eventRepr; }
[ "JsonRepresentation", "asEventRepr", "(", "EventMetadata", "metadata", ",", "final", "JsonRepresentation", "payloadRepr", ")", "{", "final", "JsonRepresentation", "eventRepr", "=", "JsonRepresentation", ".", "newMap", "(", ")", ";", "final", "JsonRepresentation", "metadataRepr", "=", "JsonRepresentation", ".", "newMap", "(", ")", ";", "eventRepr", ".", "mapPut", "(", "\"metadata\"", ",", "metadataRepr", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"id\"", ",", "metadata", ".", "getId", "(", ")", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"transactionId\"", ",", "metadata", ".", "getTransactionId", "(", ")", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"sequence\"", ",", "metadata", ".", "getSequence", "(", ")", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"eventType\"", ",", "metadata", ".", "getEventType", "(", ")", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"user\"", ",", "metadata", ".", "getUser", "(", ")", ")", ";", "metadataRepr", ".", "mapPut", "(", "\"timestamp\"", ",", "metadata", ".", "getTimestamp", "(", ")", ")", ";", "eventRepr", ".", "mapPut", "(", "\"payload\"", ",", "payloadRepr", ")", ";", "return", "eventRepr", ";", "}" ]
region > supporting methods
[ "region", ">", "supporting", "methods" ]
9f13eab061156b70ccefd2418346dace612c1de0
https://github.com/isisaddons-legacy/isis-module-publishing/blob/9f13eab061156b70ccefd2418346dace612c1de0/dom/src/main/java/org/isisaddons/module/publishing/dom/eventserializer/RestfulObjectsSpecEventSerializer.java#L85-L97
153,275
jbundle/jbundle
main/db/src/main/java/org/jbundle/main/user/db/UpdateResourcePermissionHandler.java
UpdateResourcePermissionHandler.updateResourcePermissions
public void updateResourcePermissions() { UserPermission recUserPermission = new UserPermission(this.getOwner().findRecordOwner()); recUserPermission.addListener(new SubFileFilter(this.getOwner())); try { while (recUserPermission.hasNext()) { recUserPermission.next(); recUserPermission.edit(); recUserPermission.getField(UserPermission.USER_RESOURCE_ID).setModified(true); // Fake a mod, so the group permissions will be updated recUserPermission.set(); } } catch (DBException ex) { ex.printStackTrace(); } recUserPermission.free(); }
java
public void updateResourcePermissions() { UserPermission recUserPermission = new UserPermission(this.getOwner().findRecordOwner()); recUserPermission.addListener(new SubFileFilter(this.getOwner())); try { while (recUserPermission.hasNext()) { recUserPermission.next(); recUserPermission.edit(); recUserPermission.getField(UserPermission.USER_RESOURCE_ID).setModified(true); // Fake a mod, so the group permissions will be updated recUserPermission.set(); } } catch (DBException ex) { ex.printStackTrace(); } recUserPermission.free(); }
[ "public", "void", "updateResourcePermissions", "(", ")", "{", "UserPermission", "recUserPermission", "=", "new", "UserPermission", "(", "this", ".", "getOwner", "(", ")", ".", "findRecordOwner", "(", ")", ")", ";", "recUserPermission", ".", "addListener", "(", "new", "SubFileFilter", "(", "this", ".", "getOwner", "(", ")", ")", ")", ";", "try", "{", "while", "(", "recUserPermission", ".", "hasNext", "(", ")", ")", "{", "recUserPermission", ".", "next", "(", ")", ";", "recUserPermission", ".", "edit", "(", ")", ";", "recUserPermission", ".", "getField", "(", "UserPermission", ".", "USER_RESOURCE_ID", ")", ".", "setModified", "(", "true", ")", ";", "// Fake a mod, so the group permissions will be updated", "recUserPermission", ".", "set", "(", ")", ";", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "recUserPermission", ".", "free", "(", ")", ";", "}" ]
UpdateResourcePermissions Method.
[ "UpdateResourcePermissions", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/db/src/main/java/org/jbundle/main/user/db/UpdateResourcePermissionHandler.java#L82-L101
153,276
jbundle/jbundle
thin/base/thread/src/main/java/org/jbundle/thin/base/thread/PrivateTaskScheduler.java
PrivateTaskScheduler.run
public void run() { Object objJobDef = null; while (m_bKeepAlive) { // Only loop, if this thread should be kept alive. Date earliestDate = null; Vector<AutoTask> vJobsToRunLater = null; while ((objJobDef = this.getNextJob()) != null) // Get and remove next job { // Until end of jobs if (EMPTY_TIMED_JOBS == objJobDef) { vJobsToRunLater = null; // Clear everything up to this job earliestDate = null; } else if (END_OF_JOBS == objJobDef) m_bKeepAlive = false; // Special - end of Jobs message, quit this thread else { if (objJobDef instanceof AutoTask) if (((AutoTask)objJobDef).getProperties() != null) { Date date = (Date)((AutoTask)objJobDef).getProperties().get(TIME_TO_RUN); if (date != null) { Date now = new Date(); if (date.after(now)) { // Don't run this one until later if ((earliestDate == null) || (earliestDate.after(date))) earliestDate = date; if (vJobsToRunLater == null) vJobsToRunLater = new Vector<AutoTask>(); this.addJobToRunLater(vJobsToRunLater, (AutoTask)objJobDef); continue; } } } if (objJobDef instanceof AutoTask) if (((AutoTask)objJobDef).getApplication() == null) ((AutoTask)objJobDef).setApplication(this.getApplication()); this.runThread(objJobDef); } } long lWaitTime = 0; if (earliestDate != null) { lWaitTime = earliestDate.getTime() - new Date().getTime(); if (lWaitTime <= 0) lWaitTime = 1; // Don't wait (long) there is a task that is ready to go now. } // No more tasks to process, either stop, or go to sleep if (m_bKeepAlive) { synchronized(this) { m_bThreadSuspended = true; // Suspend this puppy try { while (m_bThreadSuspended) { wait(lWaitTime); // Wait for notification that I can continue if (lWaitTime != 0) { m_bThreadSuspended = false; // I was waiting for the time to expire. m_vPrivateJobs.addAll(vJobsToRunLater); // Add all these jobs back } } } catch (InterruptedException ex) { ex.printStackTrace(); } } } } }
java
public void run() { Object objJobDef = null; while (m_bKeepAlive) { // Only loop, if this thread should be kept alive. Date earliestDate = null; Vector<AutoTask> vJobsToRunLater = null; while ((objJobDef = this.getNextJob()) != null) // Get and remove next job { // Until end of jobs if (EMPTY_TIMED_JOBS == objJobDef) { vJobsToRunLater = null; // Clear everything up to this job earliestDate = null; } else if (END_OF_JOBS == objJobDef) m_bKeepAlive = false; // Special - end of Jobs message, quit this thread else { if (objJobDef instanceof AutoTask) if (((AutoTask)objJobDef).getProperties() != null) { Date date = (Date)((AutoTask)objJobDef).getProperties().get(TIME_TO_RUN); if (date != null) { Date now = new Date(); if (date.after(now)) { // Don't run this one until later if ((earliestDate == null) || (earliestDate.after(date))) earliestDate = date; if (vJobsToRunLater == null) vJobsToRunLater = new Vector<AutoTask>(); this.addJobToRunLater(vJobsToRunLater, (AutoTask)objJobDef); continue; } } } if (objJobDef instanceof AutoTask) if (((AutoTask)objJobDef).getApplication() == null) ((AutoTask)objJobDef).setApplication(this.getApplication()); this.runThread(objJobDef); } } long lWaitTime = 0; if (earliestDate != null) { lWaitTime = earliestDate.getTime() - new Date().getTime(); if (lWaitTime <= 0) lWaitTime = 1; // Don't wait (long) there is a task that is ready to go now. } // No more tasks to process, either stop, or go to sleep if (m_bKeepAlive) { synchronized(this) { m_bThreadSuspended = true; // Suspend this puppy try { while (m_bThreadSuspended) { wait(lWaitTime); // Wait for notification that I can continue if (lWaitTime != 0) { m_bThreadSuspended = false; // I was waiting for the time to expire. m_vPrivateJobs.addAll(vJobsToRunLater); // Add all these jobs back } } } catch (InterruptedException ex) { ex.printStackTrace(); } } } } }
[ "public", "void", "run", "(", ")", "{", "Object", "objJobDef", "=", "null", ";", "while", "(", "m_bKeepAlive", ")", "{", "// Only loop, if this thread should be kept alive.", "Date", "earliestDate", "=", "null", ";", "Vector", "<", "AutoTask", ">", "vJobsToRunLater", "=", "null", ";", "while", "(", "(", "objJobDef", "=", "this", ".", "getNextJob", "(", ")", ")", "!=", "null", ")", "// Get and remove next job", "{", "// Until end of jobs", "if", "(", "EMPTY_TIMED_JOBS", "==", "objJobDef", ")", "{", "vJobsToRunLater", "=", "null", ";", "// Clear everything up to this job", "earliestDate", "=", "null", ";", "}", "else", "if", "(", "END_OF_JOBS", "==", "objJobDef", ")", "m_bKeepAlive", "=", "false", ";", "// Special - end of Jobs message, quit this thread", "else", "{", "if", "(", "objJobDef", "instanceof", "AutoTask", ")", "if", "(", "(", "(", "AutoTask", ")", "objJobDef", ")", ".", "getProperties", "(", ")", "!=", "null", ")", "{", "Date", "date", "=", "(", "Date", ")", "(", "(", "AutoTask", ")", "objJobDef", ")", ".", "getProperties", "(", ")", ".", "get", "(", "TIME_TO_RUN", ")", ";", "if", "(", "date", "!=", "null", ")", "{", "Date", "now", "=", "new", "Date", "(", ")", ";", "if", "(", "date", ".", "after", "(", "now", ")", ")", "{", "// Don't run this one until later", "if", "(", "(", "earliestDate", "==", "null", ")", "||", "(", "earliestDate", ".", "after", "(", "date", ")", ")", ")", "earliestDate", "=", "date", ";", "if", "(", "vJobsToRunLater", "==", "null", ")", "vJobsToRunLater", "=", "new", "Vector", "<", "AutoTask", ">", "(", ")", ";", "this", ".", "addJobToRunLater", "(", "vJobsToRunLater", ",", "(", "AutoTask", ")", "objJobDef", ")", ";", "continue", ";", "}", "}", "}", "if", "(", "objJobDef", "instanceof", "AutoTask", ")", "if", "(", "(", "(", "AutoTask", ")", "objJobDef", ")", ".", "getApplication", "(", ")", "==", "null", ")", "(", "(", "AutoTask", ")", "objJobDef", ")", ".", "setApplication", "(", "this", ".", "getApplication", "(", ")", ")", ";", "this", ".", "runThread", "(", "objJobDef", ")", ";", "}", "}", "long", "lWaitTime", "=", "0", ";", "if", "(", "earliestDate", "!=", "null", ")", "{", "lWaitTime", "=", "earliestDate", ".", "getTime", "(", ")", "-", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "if", "(", "lWaitTime", "<=", "0", ")", "lWaitTime", "=", "1", ";", "// Don't wait (long) there is a task that is ready to go now.", "}", "// No more tasks to process, either stop, or go to sleep", "if", "(", "m_bKeepAlive", ")", "{", "synchronized", "(", "this", ")", "{", "m_bThreadSuspended", "=", "true", ";", "// Suspend this puppy", "try", "{", "while", "(", "m_bThreadSuspended", ")", "{", "wait", "(", "lWaitTime", ")", ";", "// Wait for notification that I can continue", "if", "(", "lWaitTime", "!=", "0", ")", "{", "m_bThreadSuspended", "=", "false", ";", "// I was waiting for the time to expire.", "m_vPrivateJobs", ".", "addAll", "(", "vJobsToRunLater", ")", ";", "// Add all these jobs back", "}", "}", "}", "catch", "(", "InterruptedException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "}", "}" ]
Run this thread.
[ "Run", "this", "thread", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/thread/src/main/java/org/jbundle/thin/base/thread/PrivateTaskScheduler.java#L125-L197
153,277
jbundle/jbundle
thin/base/thread/src/main/java/org/jbundle/thin/base/thread/PrivateTaskScheduler.java
PrivateTaskScheduler.sameJob
public boolean sameJob(AutoTask jobAtIndex, AutoTask jobToAdd) { Map<String, Object> propJobAtIndex = jobAtIndex.getProperties(); Map<String, Object> propJobToAdd = jobToAdd.getProperties(); if (propJobAtIndex.size() != propJobToAdd.size()) return false; boolean bSameJob = false; // They are equal if every property (except time) match for (String strNewKey : propJobToAdd.keySet()) { if (!strNewKey.equalsIgnoreCase(TIME_TO_RUN)) { if (propJobAtIndex.get(strNewKey).equals(propJobToAdd.get(strNewKey))) bSameJob = true; // Okay, this is a potential match else return false; // This property doesn't match, stop compare } } return bSameJob; }
java
public boolean sameJob(AutoTask jobAtIndex, AutoTask jobToAdd) { Map<String, Object> propJobAtIndex = jobAtIndex.getProperties(); Map<String, Object> propJobToAdd = jobToAdd.getProperties(); if (propJobAtIndex.size() != propJobToAdd.size()) return false; boolean bSameJob = false; // They are equal if every property (except time) match for (String strNewKey : propJobToAdd.keySet()) { if (!strNewKey.equalsIgnoreCase(TIME_TO_RUN)) { if (propJobAtIndex.get(strNewKey).equals(propJobToAdd.get(strNewKey))) bSameJob = true; // Okay, this is a potential match else return false; // This property doesn't match, stop compare } } return bSameJob; }
[ "public", "boolean", "sameJob", "(", "AutoTask", "jobAtIndex", ",", "AutoTask", "jobToAdd", ")", "{", "Map", "<", "String", ",", "Object", ">", "propJobAtIndex", "=", "jobAtIndex", ".", "getProperties", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "propJobToAdd", "=", "jobToAdd", ".", "getProperties", "(", ")", ";", "if", "(", "propJobAtIndex", ".", "size", "(", ")", "!=", "propJobToAdd", ".", "size", "(", ")", ")", "return", "false", ";", "boolean", "bSameJob", "=", "false", ";", "// They are equal if every property (except time) match", "for", "(", "String", "strNewKey", ":", "propJobToAdd", ".", "keySet", "(", ")", ")", "{", "if", "(", "!", "strNewKey", ".", "equalsIgnoreCase", "(", "TIME_TO_RUN", ")", ")", "{", "if", "(", "propJobAtIndex", ".", "get", "(", "strNewKey", ")", ".", "equals", "(", "propJobToAdd", ".", "get", "(", "strNewKey", ")", ")", ")", "bSameJob", "=", "true", ";", "// Okay, this is a potential match", "else", "return", "false", ";", "// This property doesn't match, stop compare", "}", "}", "return", "bSameJob", ";", "}" ]
Do these two jobs match? @param propJobAtIndex @param propJobToAdd @return
[ "Do", "these", "two", "jobs", "match?" ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/thread/src/main/java/org/jbundle/thin/base/thread/PrivateTaskScheduler.java#L235-L255
153,278
jbundle/jbundle
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/message/ThinMessageManager.java
ThinMessageManager.createScreenMessageListener
public static JMessageListener createScreenMessageListener(FieldList record, BaseScreenModel screen) { // Now add listeners to update screen when data changes FieldTable table = record.getTable(); RemoteSession remoteSession = (RemoteSession)table.getRemoteTableType(org.jbundle.model.Remote.class); MessageManager messageManager = ((Application)screen.getBaseApplet().getApplication()).getMessageManager(); MessageReceiver handler = messageManager.getMessageQueue(MessageConstants.RECORD_QUEUE_NAME, MessageConstants.INTRANET_QUEUE).getMessageReceiver(); Properties properties = new Properties(); JMessageListener listenerForSession = (JMessageListener)screen.addMessageHandler(record, properties); BaseMessageFilter filterForSession = new ClientSessionMessageFilter(MessageConstants.RECORD_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, screen, remoteSession, properties); filterForSession.addMessageListener(listenerForSession); synchronized (screen.getBaseApplet().getRemoteTask()) { // Wait for remote filter to set up before I start accessing the data handler.addMessageFilter(filterForSession); } return listenerForSession; }
java
public static JMessageListener createScreenMessageListener(FieldList record, BaseScreenModel screen) { // Now add listeners to update screen when data changes FieldTable table = record.getTable(); RemoteSession remoteSession = (RemoteSession)table.getRemoteTableType(org.jbundle.model.Remote.class); MessageManager messageManager = ((Application)screen.getBaseApplet().getApplication()).getMessageManager(); MessageReceiver handler = messageManager.getMessageQueue(MessageConstants.RECORD_QUEUE_NAME, MessageConstants.INTRANET_QUEUE).getMessageReceiver(); Properties properties = new Properties(); JMessageListener listenerForSession = (JMessageListener)screen.addMessageHandler(record, properties); BaseMessageFilter filterForSession = new ClientSessionMessageFilter(MessageConstants.RECORD_QUEUE_NAME, MessageConstants.INTRANET_QUEUE, screen, remoteSession, properties); filterForSession.addMessageListener(listenerForSession); synchronized (screen.getBaseApplet().getRemoteTask()) { // Wait for remote filter to set up before I start accessing the data handler.addMessageFilter(filterForSession); } return listenerForSession; }
[ "public", "static", "JMessageListener", "createScreenMessageListener", "(", "FieldList", "record", ",", "BaseScreenModel", "screen", ")", "{", "// Now add listeners to update screen when data changes", "FieldTable", "table", "=", "record", ".", "getTable", "(", ")", ";", "RemoteSession", "remoteSession", "=", "(", "RemoteSession", ")", "table", ".", "getRemoteTableType", "(", "org", ".", "jbundle", ".", "model", ".", "Remote", ".", "class", ")", ";", "MessageManager", "messageManager", "=", "(", "(", "Application", ")", "screen", ".", "getBaseApplet", "(", ")", ".", "getApplication", "(", ")", ")", ".", "getMessageManager", "(", ")", ";", "MessageReceiver", "handler", "=", "messageManager", ".", "getMessageQueue", "(", "MessageConstants", ".", "RECORD_QUEUE_NAME", ",", "MessageConstants", ".", "INTRANET_QUEUE", ")", ".", "getMessageReceiver", "(", ")", ";", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "JMessageListener", "listenerForSession", "=", "(", "JMessageListener", ")", "screen", ".", "addMessageHandler", "(", "record", ",", "properties", ")", ";", "BaseMessageFilter", "filterForSession", "=", "new", "ClientSessionMessageFilter", "(", "MessageConstants", ".", "RECORD_QUEUE_NAME", ",", "MessageConstants", ".", "INTRANET_QUEUE", ",", "screen", ",", "remoteSession", ",", "properties", ")", ";", "filterForSession", ".", "addMessageListener", "(", "listenerForSession", ")", ";", "synchronized", "(", "screen", ".", "getBaseApplet", "(", ")", ".", "getRemoteTask", "(", ")", ")", "{", "// Wait for remote filter to set up before I start accessing the data", "handler", ".", "addMessageFilter", "(", "filterForSession", ")", ";", "}", "return", "listenerForSession", ";", "}" ]
Create a screen message listener for this screen.
[ "Create", "a", "screen", "message", "listener", "for", "this", "screen", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/message/ThinMessageManager.java#L67-L86
153,279
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL11.java
GetWSDL11.processPortType
public String processPortType(TDefinitions descriptionType, TPortType interfaceType, boolean addAddress) { String interfaceName = interfaceType.getName(); String allAddress = DBConstants.BLANK; for (TOperation nextElement : interfaceType.getOperation()) { { String address = this.processInterfaceOperationType(descriptionType, interfaceName, nextElement, addAddress); if (allAddress != null) { if (allAddress == DBConstants.BLANK) allAddress = address; else if (!allAddress.equalsIgnoreCase(address)) allAddress = null; // null = not all address are the same } } } return allAddress; }
java
public String processPortType(TDefinitions descriptionType, TPortType interfaceType, boolean addAddress) { String interfaceName = interfaceType.getName(); String allAddress = DBConstants.BLANK; for (TOperation nextElement : interfaceType.getOperation()) { { String address = this.processInterfaceOperationType(descriptionType, interfaceName, nextElement, addAddress); if (allAddress != null) { if (allAddress == DBConstants.BLANK) allAddress = address; else if (!allAddress.equalsIgnoreCase(address)) allAddress = null; // null = not all address are the same } } } return allAddress; }
[ "public", "String", "processPortType", "(", "TDefinitions", "descriptionType", ",", "TPortType", "interfaceType", ",", "boolean", "addAddress", ")", "{", "String", "interfaceName", "=", "interfaceType", ".", "getName", "(", ")", ";", "String", "allAddress", "=", "DBConstants", ".", "BLANK", ";", "for", "(", "TOperation", "nextElement", ":", "interfaceType", ".", "getOperation", "(", ")", ")", "{", "{", "String", "address", "=", "this", ".", "processInterfaceOperationType", "(", "descriptionType", ",", "interfaceName", ",", "nextElement", ",", "addAddress", ")", ";", "if", "(", "allAddress", "!=", "null", ")", "{", "if", "(", "allAddress", "==", "DBConstants", ".", "BLANK", ")", "allAddress", "=", "address", ";", "else", "if", "(", "!", "allAddress", ".", "equalsIgnoreCase", "(", "address", ")", ")", "allAddress", "=", "null", ";", "// null = not all address are the same", "}", "}", "}", "return", "allAddress", ";", "}" ]
ProcessPortType Method.
[ "ProcessPortType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL11.java#L104-L124
153,280
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL11.java
GetWSDL11.getElementNameFromMessageName
public String getElementNameFromMessageName(TDefinitions descriptionType, TParam message) { QName qName = message.getMessage(); String name = qName.getLocalPart(); for (TDocumented nextElement : descriptionType.getAnyTopLevelOptionalElement()) { // Create the service type if (nextElement instanceof TMessage) { String msgName = ((TMessage)nextElement).getName(); for (TPart part : ((TMessage)nextElement).getPart()) { if (name.equals(part.getName())) { return part.getElement().getLocalPart(); } } } } return null; }
java
public String getElementNameFromMessageName(TDefinitions descriptionType, TParam message) { QName qName = message.getMessage(); String name = qName.getLocalPart(); for (TDocumented nextElement : descriptionType.getAnyTopLevelOptionalElement()) { // Create the service type if (nextElement instanceof TMessage) { String msgName = ((TMessage)nextElement).getName(); for (TPart part : ((TMessage)nextElement).getPart()) { if (name.equals(part.getName())) { return part.getElement().getLocalPart(); } } } } return null; }
[ "public", "String", "getElementNameFromMessageName", "(", "TDefinitions", "descriptionType", ",", "TParam", "message", ")", "{", "QName", "qName", "=", "message", ".", "getMessage", "(", ")", ";", "String", "name", "=", "qName", ".", "getLocalPart", "(", ")", ";", "for", "(", "TDocumented", "nextElement", ":", "descriptionType", ".", "getAnyTopLevelOptionalElement", "(", ")", ")", "{", "// Create the service type", "if", "(", "nextElement", "instanceof", "TMessage", ")", "{", "String", "msgName", "=", "(", "(", "TMessage", ")", "nextElement", ")", ".", "getName", "(", ")", ";", "for", "(", "TPart", "part", ":", "(", "(", "TMessage", ")", "nextElement", ")", ".", "getPart", "(", ")", ")", "{", "if", "(", "name", ".", "equals", "(", "part", ".", "getName", "(", ")", ")", ")", "{", "return", "part", ".", "getElement", "(", ")", ".", "getLocalPart", "(", ")", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Search through the messages for this one and return the element name.
[ "Search", "through", "the", "messages", "for", "this", "one", "and", "return", "the", "element", "name", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL11.java#L167-L187
153,281
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java
ESigService.init
private void init(IESigType eSigType) { List<ESigItem> list = new ArrayList<>(); eSigType.loadESigItems(list); eSigList.addAll(list); }
java
private void init(IESigType eSigType) { List<ESigItem> list = new ArrayList<>(); eSigType.loadESigItems(list); eSigList.addAll(list); }
[ "private", "void", "init", "(", "IESigType", "eSigType", ")", "{", "List", "<", "ESigItem", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "eSigType", ".", "loadESigItems", "(", "list", ")", ";", "eSigList", ".", "addAll", "(", "list", ")", ";", "}" ]
Initialize a new esig type. @param eSigType The esignature type.
[ "Initialize", "a", "new", "esig", "type", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java#L100-L104
153,282
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java
ESigService.exist
@Override public boolean exist(IESigType esigType, String id) { return eSigList.indexOf(esigType, id) >= 0; }
java
@Override public boolean exist(IESigType esigType, String id) { return eSigList.indexOf(esigType, id) >= 0; }
[ "@", "Override", "public", "boolean", "exist", "(", "IESigType", "esigType", ",", "String", "id", ")", "{", "return", "eSigList", ".", "indexOf", "(", "esigType", ",", "id", ")", ">=", "0", ";", "}" ]
Tests if the esig item of the specified type and unique id exists. @param esigType The esig type. @param id The unique id. @return True if a matching item exists in the list.
[ "Tests", "if", "the", "esig", "item", "of", "the", "specified", "type", "and", "unique", "id", "exists", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java#L127-L130
153,283
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java
ESigService.remove
@Override public void remove(IESigType esigType, String id) { eSigList.remove(esigType, id); }
java
@Override public void remove(IESigType esigType, String id) { eSigList.remove(esigType, id); }
[ "@", "Override", "public", "void", "remove", "(", "IESigType", "esigType", ",", "String", "id", ")", "{", "eSigList", ".", "remove", "(", "esigType", ",", "id", ")", ";", "}" ]
Removes the item of the specified type and id from the list. @param esigType The esig type. @param id The unique id.
[ "Removes", "the", "item", "of", "the", "specified", "type", "and", "id", "from", "the", "list", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java#L162-L165
153,284
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java
ESigService.register
@Override public void register(IESigType eSigType) throws Exception { if (typeRegistry.get(eSigType.getESigTypeId()) != null) { throw new Exception("Duplicate esig type identifier: " + eSigType.getESigTypeId()); } typeRegistry.put(eSigType.getESigTypeId(), eSigType); init(eSigType); }
java
@Override public void register(IESigType eSigType) throws Exception { if (typeRegistry.get(eSigType.getESigTypeId()) != null) { throw new Exception("Duplicate esig type identifier: " + eSigType.getESigTypeId()); } typeRegistry.put(eSigType.getESigTypeId(), eSigType); init(eSigType); }
[ "@", "Override", "public", "void", "register", "(", "IESigType", "eSigType", ")", "throws", "Exception", "{", "if", "(", "typeRegistry", ".", "get", "(", "eSigType", ".", "getESigTypeId", "(", ")", ")", "!=", "null", ")", "{", "throw", "new", "Exception", "(", "\"Duplicate esig type identifier: \"", "+", "eSigType", ".", "getESigTypeId", "(", ")", ")", ";", "}", "typeRegistry", ".", "put", "(", "eSigType", ".", "getESigTypeId", "(", ")", ",", "eSigType", ")", ";", "init", "(", "eSigType", ")", ";", "}" ]
Registers a new esig type. If a type with the same mnemonic id is already registered, an exception is thrown. @param eSigType The new type to register.
[ "Registers", "a", "new", "esig", "type", ".", "If", "a", "type", "with", "the", "same", "mnemonic", "id", "is", "already", "registered", "an", "exception", "is", "thrown", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigService.java#L245-L253
153,285
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.compare
public static void compare(final IFileCompareResultBean fileCompareResultBean, final boolean ignoreAbsolutePathEquality, final boolean ignoreExtensionEquality, final boolean ignoreLengthEquality, final boolean ignoreLastModified, final boolean ignoreNameEquality) { final File source = fileCompareResultBean.getSourceFile(); final File compare = fileCompareResultBean.getFileToCompare(); if (!ignoreAbsolutePathEquality) { // check the absolute path from the files... final String sourceAbsolutePath = source.getAbsolutePath(); final String compareAbsolutePath = compare.getAbsolutePath(); final boolean absolutePathEquality = sourceAbsolutePath.equals(compareAbsolutePath); fileCompareResultBean.setAbsolutePathEquality(absolutePathEquality); } else { fileCompareResultBean.setAbsolutePathEquality(true); } if (!ignoreExtensionEquality) { // check the file extension... final String sourceFileExtension = FileExtensions.getFilenameSuffix(source); final String compareFileExtension = FileExtensions.getFilenameSuffix(compare); final boolean extensionEquality = compareFileExtension .equalsIgnoreCase(sourceFileExtension); fileCompareResultBean.setFileExtensionEquality(extensionEquality); } else { fileCompareResultBean.setFileExtensionEquality(true); } if (!ignoreLengthEquality) { // check the file length... final boolean length = source.length() == compare.length(); fileCompareResultBean.setLengthEquality(length); } else { fileCompareResultBean.setLengthEquality(true); } if (!ignoreLastModified) { // check the last modified date... final boolean lastModified = source.lastModified() == compare.lastModified(); fileCompareResultBean.setLastModifiedEquality(lastModified); } else { fileCompareResultBean.setLastModifiedEquality(true); } if (!ignoreNameEquality) { // check the filename... final String sourceFilename = FileExtensions.getFilenameWithoutExtension(source); final String compareFilename = FileExtensions.getFilenameWithoutExtension(compare); final boolean nameEquality = compareFilename.equalsIgnoreCase(sourceFilename); fileCompareResultBean.setNameEquality(nameEquality); } else { fileCompareResultBean.setNameEquality(true); } }
java
public static void compare(final IFileCompareResultBean fileCompareResultBean, final boolean ignoreAbsolutePathEquality, final boolean ignoreExtensionEquality, final boolean ignoreLengthEquality, final boolean ignoreLastModified, final boolean ignoreNameEquality) { final File source = fileCompareResultBean.getSourceFile(); final File compare = fileCompareResultBean.getFileToCompare(); if (!ignoreAbsolutePathEquality) { // check the absolute path from the files... final String sourceAbsolutePath = source.getAbsolutePath(); final String compareAbsolutePath = compare.getAbsolutePath(); final boolean absolutePathEquality = sourceAbsolutePath.equals(compareAbsolutePath); fileCompareResultBean.setAbsolutePathEquality(absolutePathEquality); } else { fileCompareResultBean.setAbsolutePathEquality(true); } if (!ignoreExtensionEquality) { // check the file extension... final String sourceFileExtension = FileExtensions.getFilenameSuffix(source); final String compareFileExtension = FileExtensions.getFilenameSuffix(compare); final boolean extensionEquality = compareFileExtension .equalsIgnoreCase(sourceFileExtension); fileCompareResultBean.setFileExtensionEquality(extensionEquality); } else { fileCompareResultBean.setFileExtensionEquality(true); } if (!ignoreLengthEquality) { // check the file length... final boolean length = source.length() == compare.length(); fileCompareResultBean.setLengthEquality(length); } else { fileCompareResultBean.setLengthEquality(true); } if (!ignoreLastModified) { // check the last modified date... final boolean lastModified = source.lastModified() == compare.lastModified(); fileCompareResultBean.setLastModifiedEquality(lastModified); } else { fileCompareResultBean.setLastModifiedEquality(true); } if (!ignoreNameEquality) { // check the filename... final String sourceFilename = FileExtensions.getFilenameWithoutExtension(source); final String compareFilename = FileExtensions.getFilenameWithoutExtension(compare); final boolean nameEquality = compareFilename.equalsIgnoreCase(sourceFilename); fileCompareResultBean.setNameEquality(nameEquality); } else { fileCompareResultBean.setNameEquality(true); } }
[ "public", "static", "void", "compare", "(", "final", "IFileCompareResultBean", "fileCompareResultBean", ",", "final", "boolean", "ignoreAbsolutePathEquality", ",", "final", "boolean", "ignoreExtensionEquality", ",", "final", "boolean", "ignoreLengthEquality", ",", "final", "boolean", "ignoreLastModified", ",", "final", "boolean", "ignoreNameEquality", ")", "{", "final", "File", "source", "=", "fileCompareResultBean", ".", "getSourceFile", "(", ")", ";", "final", "File", "compare", "=", "fileCompareResultBean", ".", "getFileToCompare", "(", ")", ";", "if", "(", "!", "ignoreAbsolutePathEquality", ")", "{", "// check the absolute path from the files...", "final", "String", "sourceAbsolutePath", "=", "source", ".", "getAbsolutePath", "(", ")", ";", "final", "String", "compareAbsolutePath", "=", "compare", ".", "getAbsolutePath", "(", ")", ";", "final", "boolean", "absolutePathEquality", "=", "sourceAbsolutePath", ".", "equals", "(", "compareAbsolutePath", ")", ";", "fileCompareResultBean", ".", "setAbsolutePathEquality", "(", "absolutePathEquality", ")", ";", "}", "else", "{", "fileCompareResultBean", ".", "setAbsolutePathEquality", "(", "true", ")", ";", "}", "if", "(", "!", "ignoreExtensionEquality", ")", "{", "// check the file extension...", "final", "String", "sourceFileExtension", "=", "FileExtensions", ".", "getFilenameSuffix", "(", "source", ")", ";", "final", "String", "compareFileExtension", "=", "FileExtensions", ".", "getFilenameSuffix", "(", "compare", ")", ";", "final", "boolean", "extensionEquality", "=", "compareFileExtension", ".", "equalsIgnoreCase", "(", "sourceFileExtension", ")", ";", "fileCompareResultBean", ".", "setFileExtensionEquality", "(", "extensionEquality", ")", ";", "}", "else", "{", "fileCompareResultBean", ".", "setFileExtensionEquality", "(", "true", ")", ";", "}", "if", "(", "!", "ignoreLengthEquality", ")", "{", "// check the file length...", "final", "boolean", "length", "=", "source", ".", "length", "(", ")", "==", "compare", ".", "length", "(", ")", ";", "fileCompareResultBean", ".", "setLengthEquality", "(", "length", ")", ";", "}", "else", "{", "fileCompareResultBean", ".", "setLengthEquality", "(", "true", ")", ";", "}", "if", "(", "!", "ignoreLastModified", ")", "{", "// check the last modified date...", "final", "boolean", "lastModified", "=", "source", ".", "lastModified", "(", ")", "==", "compare", ".", "lastModified", "(", ")", ";", "fileCompareResultBean", ".", "setLastModifiedEquality", "(", "lastModified", ")", ";", "}", "else", "{", "fileCompareResultBean", ".", "setLastModifiedEquality", "(", "true", ")", ";", "}", "if", "(", "!", "ignoreNameEquality", ")", "{", "// check the filename...", "final", "String", "sourceFilename", "=", "FileExtensions", ".", "getFilenameWithoutExtension", "(", "source", ")", ";", "final", "String", "compareFilename", "=", "FileExtensions", ".", "getFilenameWithoutExtension", "(", "compare", ")", ";", "final", "boolean", "nameEquality", "=", "compareFilename", ".", "equalsIgnoreCase", "(", "sourceFilename", ")", ";", "fileCompareResultBean", ".", "setNameEquality", "(", "nameEquality", ")", ";", "}", "else", "{", "fileCompareResultBean", ".", "setNameEquality", "(", "true", ")", ";", "}", "}" ]
Sets the flags in the FileCompareResultBean object according to the given boolean flag what to ignore. @param fileCompareResultBean The FileCompareResultBean. @param ignoreAbsolutePathEquality If this is true then the absolute path equality will be ignored. @param ignoreExtensionEquality If this is true then the extension equality will be ignored. @param ignoreLengthEquality If this is true then the length equality will be ignored. @param ignoreLastModified If this is true then the last modified equality will be ignored. @param ignoreNameEquality If this is true then the name equality will be ignored.
[ "Sets", "the", "flags", "in", "the", "FileCompareResultBean", "object", "according", "to", "the", "given", "boolean", "flag", "what", "to", "ignore", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L72-L140
153,286
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.compare
public static void compare(final IFileContentResultBean fileContentResultBean, final boolean ignoreAbsolutePathEquality, final boolean ignoreExtensionEquality, final boolean ignoreLengthEquality, final boolean ignoreLastModified, final boolean ignoreNameEquality, final boolean ignoreContentEquality) { compare(fileContentResultBean, ignoreAbsolutePathEquality, ignoreExtensionEquality, ignoreLengthEquality, ignoreLastModified, ignoreNameEquality); final File source = fileContentResultBean.getSourceFile(); final File compare = fileContentResultBean.getFileToCompare(); if (!ignoreContentEquality) { boolean contentEquality; try { final String sourceChecksum = ChecksumExtensions.getChecksum(source, HashAlgorithm.SHA_512.getAlgorithm()); final String compareChecksum = ChecksumExtensions.getChecksum(compare, HashAlgorithm.SHA_512.getAlgorithm()); contentEquality = sourceChecksum.equals(compareChecksum); fileContentResultBean.setContentEquality(contentEquality); } catch (final NoSuchAlgorithmException e) { // if the algorithm is not supported check it with CRC32. try { contentEquality = ChecksumExtensions .getCheckSumCRC32(source) == ChecksumExtensions.getCheckSumCRC32(compare); fileContentResultBean.setContentEquality(contentEquality); } catch (IOException e1) { fileContentResultBean.setContentEquality(false); } } catch (IOException e) { fileContentResultBean.setContentEquality(false); } } else { fileContentResultBean.setContentEquality(true); } }
java
public static void compare(final IFileContentResultBean fileContentResultBean, final boolean ignoreAbsolutePathEquality, final boolean ignoreExtensionEquality, final boolean ignoreLengthEquality, final boolean ignoreLastModified, final boolean ignoreNameEquality, final boolean ignoreContentEquality) { compare(fileContentResultBean, ignoreAbsolutePathEquality, ignoreExtensionEquality, ignoreLengthEquality, ignoreLastModified, ignoreNameEquality); final File source = fileContentResultBean.getSourceFile(); final File compare = fileContentResultBean.getFileToCompare(); if (!ignoreContentEquality) { boolean contentEquality; try { final String sourceChecksum = ChecksumExtensions.getChecksum(source, HashAlgorithm.SHA_512.getAlgorithm()); final String compareChecksum = ChecksumExtensions.getChecksum(compare, HashAlgorithm.SHA_512.getAlgorithm()); contentEquality = sourceChecksum.equals(compareChecksum); fileContentResultBean.setContentEquality(contentEquality); } catch (final NoSuchAlgorithmException e) { // if the algorithm is not supported check it with CRC32. try { contentEquality = ChecksumExtensions .getCheckSumCRC32(source) == ChecksumExtensions.getCheckSumCRC32(compare); fileContentResultBean.setContentEquality(contentEquality); } catch (IOException e1) { fileContentResultBean.setContentEquality(false); } } catch (IOException e) { fileContentResultBean.setContentEquality(false); } } else { fileContentResultBean.setContentEquality(true); } }
[ "public", "static", "void", "compare", "(", "final", "IFileContentResultBean", "fileContentResultBean", ",", "final", "boolean", "ignoreAbsolutePathEquality", ",", "final", "boolean", "ignoreExtensionEquality", ",", "final", "boolean", "ignoreLengthEquality", ",", "final", "boolean", "ignoreLastModified", ",", "final", "boolean", "ignoreNameEquality", ",", "final", "boolean", "ignoreContentEquality", ")", "{", "compare", "(", "fileContentResultBean", ",", "ignoreAbsolutePathEquality", ",", "ignoreExtensionEquality", ",", "ignoreLengthEquality", ",", "ignoreLastModified", ",", "ignoreNameEquality", ")", ";", "final", "File", "source", "=", "fileContentResultBean", ".", "getSourceFile", "(", ")", ";", "final", "File", "compare", "=", "fileContentResultBean", ".", "getFileToCompare", "(", ")", ";", "if", "(", "!", "ignoreContentEquality", ")", "{", "boolean", "contentEquality", ";", "try", "{", "final", "String", "sourceChecksum", "=", "ChecksumExtensions", ".", "getChecksum", "(", "source", ",", "HashAlgorithm", ".", "SHA_512", ".", "getAlgorithm", "(", ")", ")", ";", "final", "String", "compareChecksum", "=", "ChecksumExtensions", ".", "getChecksum", "(", "compare", ",", "HashAlgorithm", ".", "SHA_512", ".", "getAlgorithm", "(", ")", ")", ";", "contentEquality", "=", "sourceChecksum", ".", "equals", "(", "compareChecksum", ")", ";", "fileContentResultBean", ".", "setContentEquality", "(", "contentEquality", ")", ";", "}", "catch", "(", "final", "NoSuchAlgorithmException", "e", ")", "{", "// if the algorithm is not supported check it with CRC32.", "try", "{", "contentEquality", "=", "ChecksumExtensions", ".", "getCheckSumCRC32", "(", "source", ")", "==", "ChecksumExtensions", ".", "getCheckSumCRC32", "(", "compare", ")", ";", "fileContentResultBean", ".", "setContentEquality", "(", "contentEquality", ")", ";", "}", "catch", "(", "IOException", "e1", ")", "{", "fileContentResultBean", ".", "setContentEquality", "(", "false", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "fileContentResultBean", ".", "setContentEquality", "(", "false", ")", ";", "}", "}", "else", "{", "fileContentResultBean", ".", "setContentEquality", "(", "true", ")", ";", "}", "}" ]
Sets the flags in the FileContentResultBean object according to the given boolean flag what to ignore. @param fileContentResultBean The FileContentResultBean. @param ignoreAbsolutePathEquality If this is true then the absolute path equality will be ignored. @param ignoreExtensionEquality If this is true then the extension equality will be ignored. @param ignoreLengthEquality If this is true then the length equality will be ignored. @param ignoreLastModified If this is true then the last modified equality will be ignored. @param ignoreNameEquality If this is true then the name equality will be ignored. @param ignoreContentEquality If this is true then the content equality will be ignored.
[ "Sets", "the", "flags", "in", "the", "FileContentResultBean", "object", "according", "to", "the", "given", "boolean", "flag", "what", "to", "ignore", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L161-L205
153,287
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.compareFileContentByBytes
public static IFileContentResultBean compareFileContentByBytes(final File sourceFile, final File fileToCompare) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile, fileToCompare); completeCompare(fileContentResultBean); final boolean simpleEquality = validateEquality(fileContentResultBean); boolean contentEquality = true; // Compare the content... if (simpleEquality) { try (InputStream sourceReader = StreamExtensions.getInputStream(sourceFile); InputStream compareReader = StreamExtensions.getInputStream(fileToCompare);) { final byte[] source = StreamExtensions.getByteArray(sourceReader); final byte[] compare = StreamExtensions.getByteArray(compareReader); for (int i = 0; 0 < source.length; i++) { if (source[i] != compare[i]) { contentEquality = false; break; } } } catch (final FileNotFoundException e) { contentEquality = false; } catch (final IOException e) { contentEquality = false; } } fileContentResultBean.setContentEquality(contentEquality); return fileContentResultBean; }
java
public static IFileContentResultBean compareFileContentByBytes(final File sourceFile, final File fileToCompare) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile, fileToCompare); completeCompare(fileContentResultBean); final boolean simpleEquality = validateEquality(fileContentResultBean); boolean contentEquality = true; // Compare the content... if (simpleEquality) { try (InputStream sourceReader = StreamExtensions.getInputStream(sourceFile); InputStream compareReader = StreamExtensions.getInputStream(fileToCompare);) { final byte[] source = StreamExtensions.getByteArray(sourceReader); final byte[] compare = StreamExtensions.getByteArray(compareReader); for (int i = 0; 0 < source.length; i++) { if (source[i] != compare[i]) { contentEquality = false; break; } } } catch (final FileNotFoundException e) { contentEquality = false; } catch (final IOException e) { contentEquality = false; } } fileContentResultBean.setContentEquality(contentEquality); return fileContentResultBean; }
[ "public", "static", "IFileContentResultBean", "compareFileContentByBytes", "(", "final", "File", "sourceFile", ",", "final", "File", "fileToCompare", ")", "{", "final", "IFileContentResultBean", "fileContentResultBean", "=", "new", "FileContentResultBean", "(", "sourceFile", ",", "fileToCompare", ")", ";", "completeCompare", "(", "fileContentResultBean", ")", ";", "final", "boolean", "simpleEquality", "=", "validateEquality", "(", "fileContentResultBean", ")", ";", "boolean", "contentEquality", "=", "true", ";", "// Compare the content...", "if", "(", "simpleEquality", ")", "{", "try", "(", "InputStream", "sourceReader", "=", "StreamExtensions", ".", "getInputStream", "(", "sourceFile", ")", ";", "InputStream", "compareReader", "=", "StreamExtensions", ".", "getInputStream", "(", "fileToCompare", ")", ";", ")", "{", "final", "byte", "[", "]", "source", "=", "StreamExtensions", ".", "getByteArray", "(", "sourceReader", ")", ";", "final", "byte", "[", "]", "compare", "=", "StreamExtensions", ".", "getByteArray", "(", "compareReader", ")", ";", "for", "(", "int", "i", "=", "0", ";", "0", "<", "source", ".", "length", ";", "i", "++", ")", "{", "if", "(", "source", "[", "i", "]", "!=", "compare", "[", "i", "]", ")", "{", "contentEquality", "=", "false", ";", "break", ";", "}", "}", "}", "catch", "(", "final", "FileNotFoundException", "e", ")", "{", "contentEquality", "=", "false", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "contentEquality", "=", "false", ";", "}", "}", "fileContentResultBean", ".", "setContentEquality", "(", "contentEquality", ")", ";", "return", "fileContentResultBean", ";", "}" ]
Compare file content for every single byte. @param sourceFile the source file @param fileToCompare the file to compare @return the i file content result bean
[ "Compare", "file", "content", "for", "every", "single", "byte", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L217-L255
153,288
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.compareFileContentByLines
public static IFileContentResultBean compareFileContentByLines(final File sourceFile, final File fileToCompare) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile, fileToCompare); completeCompare(fileContentResultBean); final boolean simpleEquality = validateEquality(fileContentResultBean); boolean contentEquality = true; // Compare the content... if (simpleEquality) { try ( BufferedReader sourceReader = (BufferedReader)StreamExtensions .getReader(sourceFile); BufferedReader compareReader = (BufferedReader)StreamExtensions .getReader(fileToCompare);) { String sourceLine; String compareLine; while ((sourceLine = sourceReader.readLine()) != null) { compareLine = compareReader.readLine(); if (compareLine == null || !sourceLine.equals(compareLine)) { contentEquality = false; break; } } } catch (final FileNotFoundException e) { contentEquality = false; } catch (final IOException e) { contentEquality = false; } } fileContentResultBean.setContentEquality(contentEquality); return fileContentResultBean; }
java
public static IFileContentResultBean compareFileContentByLines(final File sourceFile, final File fileToCompare) { final IFileContentResultBean fileContentResultBean = new FileContentResultBean(sourceFile, fileToCompare); completeCompare(fileContentResultBean); final boolean simpleEquality = validateEquality(fileContentResultBean); boolean contentEquality = true; // Compare the content... if (simpleEquality) { try ( BufferedReader sourceReader = (BufferedReader)StreamExtensions .getReader(sourceFile); BufferedReader compareReader = (BufferedReader)StreamExtensions .getReader(fileToCompare);) { String sourceLine; String compareLine; while ((sourceLine = sourceReader.readLine()) != null) { compareLine = compareReader.readLine(); if (compareLine == null || !sourceLine.equals(compareLine)) { contentEquality = false; break; } } } catch (final FileNotFoundException e) { contentEquality = false; } catch (final IOException e) { contentEquality = false; } } fileContentResultBean.setContentEquality(contentEquality); return fileContentResultBean; }
[ "public", "static", "IFileContentResultBean", "compareFileContentByLines", "(", "final", "File", "sourceFile", ",", "final", "File", "fileToCompare", ")", "{", "final", "IFileContentResultBean", "fileContentResultBean", "=", "new", "FileContentResultBean", "(", "sourceFile", ",", "fileToCompare", ")", ";", "completeCompare", "(", "fileContentResultBean", ")", ";", "final", "boolean", "simpleEquality", "=", "validateEquality", "(", "fileContentResultBean", ")", ";", "boolean", "contentEquality", "=", "true", ";", "// Compare the content...", "if", "(", "simpleEquality", ")", "{", "try", "(", "BufferedReader", "sourceReader", "=", "(", "BufferedReader", ")", "StreamExtensions", ".", "getReader", "(", "sourceFile", ")", ";", "BufferedReader", "compareReader", "=", "(", "BufferedReader", ")", "StreamExtensions", ".", "getReader", "(", "fileToCompare", ")", ";", ")", "{", "String", "sourceLine", ";", "String", "compareLine", ";", "while", "(", "(", "sourceLine", "=", "sourceReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "compareLine", "=", "compareReader", ".", "readLine", "(", ")", ";", "if", "(", "compareLine", "==", "null", "||", "!", "sourceLine", ".", "equals", "(", "compareLine", ")", ")", "{", "contentEquality", "=", "false", ";", "break", ";", "}", "}", "}", "catch", "(", "final", "FileNotFoundException", "e", ")", "{", "contentEquality", "=", "false", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "contentEquality", "=", "false", ";", "}", "}", "fileContentResultBean", ".", "setContentEquality", "(", "contentEquality", ")", ";", "return", "fileContentResultBean", ";", "}" ]
Compare file content by lines. @param sourceFile the source file @param fileToCompare the file to compare @return the i file content result bean
[ "Compare", "file", "content", "by", "lines", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L267-L309
153,289
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.completeCompare
public static void completeCompare(final IFileCompareResultBean fileCompareResultBean) { compare(fileCompareResultBean, false, false, false, false, false); }
java
public static void completeCompare(final IFileCompareResultBean fileCompareResultBean) { compare(fileCompareResultBean, false, false, false, false, false); }
[ "public", "static", "void", "completeCompare", "(", "final", "IFileCompareResultBean", "fileCompareResultBean", ")", "{", "compare", "(", "fileCompareResultBean", ",", "false", ",", "false", ",", "false", ",", "false", ",", "false", ")", ";", "}" ]
Completes the compare from the files encapsulated in the FileCompareResultBean. @param fileCompareResultBean the FileCompareResultBean.
[ "Completes", "the", "compare", "from", "the", "files", "encapsulated", "in", "the", "FileCompareResultBean", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L487-L490
153,290
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.findEqualFiles
public static List<IFileCompareResultBean> findEqualFiles(final File dirToSearch) { final List<File> allFiles = FileSearchExtensions.findFilesRecursive(dirToSearch, "*"); final List<IFileCompareResultBean> equalFiles = new ArrayList<>(); for (int i = 0; i < allFiles.size(); i++) { final File toCompare = allFiles.get(i); for (final File file : allFiles) { if (toCompare.equals(file)) { continue; } final IFileCompareResultBean compareResultBean = CompareFileExtensions .simpleCompareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(compareResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(compareResultBean)) { equalFiles.add(compareResultBean); } } } return equalFiles; }
java
public static List<IFileCompareResultBean> findEqualFiles(final File dirToSearch) { final List<File> allFiles = FileSearchExtensions.findFilesRecursive(dirToSearch, "*"); final List<IFileCompareResultBean> equalFiles = new ArrayList<>(); for (int i = 0; i < allFiles.size(); i++) { final File toCompare = allFiles.get(i); for (final File file : allFiles) { if (toCompare.equals(file)) { continue; } final IFileCompareResultBean compareResultBean = CompareFileExtensions .simpleCompareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(compareResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(compareResultBean)) { equalFiles.add(compareResultBean); } } } return equalFiles; }
[ "public", "static", "List", "<", "IFileCompareResultBean", ">", "findEqualFiles", "(", "final", "File", "dirToSearch", ")", "{", "final", "List", "<", "File", ">", "allFiles", "=", "FileSearchExtensions", ".", "findFilesRecursive", "(", "dirToSearch", ",", "\"*\"", ")", ";", "final", "List", "<", "IFileCompareResultBean", ">", "equalFiles", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "allFiles", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "File", "toCompare", "=", "allFiles", ".", "get", "(", "i", ")", ";", "for", "(", "final", "File", "file", ":", "allFiles", ")", "{", "if", "(", "toCompare", ".", "equals", "(", "file", ")", ")", "{", "continue", ";", "}", "final", "IFileCompareResultBean", "compareResultBean", "=", "CompareFileExtensions", ".", "simpleCompareFiles", "(", "toCompare", ",", "file", ")", ";", "final", "boolean", "equal", "=", "CompareFileExtensions", ".", "validateEquality", "(", "compareResultBean", ")", ";", "// if equal is true and the list does not contain the same", "// compareResultBean then add it.", "if", "(", "equal", "&&", "!", "equalFiles", ".", "contains", "(", "compareResultBean", ")", ")", "{", "equalFiles", ".", "add", "(", "compareResultBean", ")", ";", "}", "}", "}", "return", "equalFiles", ";", "}" ]
Find equal files. @param dirToSearch the dir to search @return the list with the result beans
[ "Find", "equal", "files", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L500-L525
153,291
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.findEqualFiles
public static List<IFileCompareResultBean> findEqualFiles(final File source, final File compare) { final List<File> allSourceFiles = FileSearchExtensions.findFilesRecursive(source, "*"); final List<File> allCompareFiles = FileSearchExtensions.findFilesRecursive(compare, "*"); final List<IFileCompareResultBean> equalFiles = new ArrayList<IFileCompareResultBean>(); for (int i = 0; i < allSourceFiles.size(); i++) { final File toCompare = allSourceFiles.get(i); for (int j = 0; j < allCompareFiles.size(); j++) { final File file = allCompareFiles.get(j); if (toCompare.equals(file)) { continue; } final IFileCompareResultBean compareResultBean = CompareFileExtensions .simpleCompareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(compareResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(compareResultBean)) { equalFiles.add(compareResultBean); } } } return equalFiles; }
java
public static List<IFileCompareResultBean> findEqualFiles(final File source, final File compare) { final List<File> allSourceFiles = FileSearchExtensions.findFilesRecursive(source, "*"); final List<File> allCompareFiles = FileSearchExtensions.findFilesRecursive(compare, "*"); final List<IFileCompareResultBean> equalFiles = new ArrayList<IFileCompareResultBean>(); for (int i = 0; i < allSourceFiles.size(); i++) { final File toCompare = allSourceFiles.get(i); for (int j = 0; j < allCompareFiles.size(); j++) { final File file = allCompareFiles.get(j); if (toCompare.equals(file)) { continue; } final IFileCompareResultBean compareResultBean = CompareFileExtensions .simpleCompareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(compareResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(compareResultBean)) { equalFiles.add(compareResultBean); } } } return equalFiles; }
[ "public", "static", "List", "<", "IFileCompareResultBean", ">", "findEqualFiles", "(", "final", "File", "source", ",", "final", "File", "compare", ")", "{", "final", "List", "<", "File", ">", "allSourceFiles", "=", "FileSearchExtensions", ".", "findFilesRecursive", "(", "source", ",", "\"*\"", ")", ";", "final", "List", "<", "File", ">", "allCompareFiles", "=", "FileSearchExtensions", ".", "findFilesRecursive", "(", "compare", ",", "\"*\"", ")", ";", "final", "List", "<", "IFileCompareResultBean", ">", "equalFiles", "=", "new", "ArrayList", "<", "IFileCompareResultBean", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "allSourceFiles", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "File", "toCompare", "=", "allSourceFiles", ".", "get", "(", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "allCompareFiles", ".", "size", "(", ")", ";", "j", "++", ")", "{", "final", "File", "file", "=", "allCompareFiles", ".", "get", "(", "j", ")", ";", "if", "(", "toCompare", ".", "equals", "(", "file", ")", ")", "{", "continue", ";", "}", "final", "IFileCompareResultBean", "compareResultBean", "=", "CompareFileExtensions", ".", "simpleCompareFiles", "(", "toCompare", ",", "file", ")", ";", "final", "boolean", "equal", "=", "CompareFileExtensions", ".", "validateEquality", "(", "compareResultBean", ")", ";", "// if equal is true and the list does not contain the same", "// compareResultBean then add it.", "if", "(", "equal", "&&", "!", "equalFiles", ".", "contains", "(", "compareResultBean", ")", ")", "{", "equalFiles", ".", "add", "(", "compareResultBean", ")", ";", "}", "}", "}", "return", "equalFiles", ";", "}" ]
Find equal files from the given directories. @param source the source directory. @param compare the directory compare. @return the list with the result beans
[ "Find", "equal", "files", "from", "the", "given", "directories", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L588-L615
153,292
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.findEqualFilesWithSameContent
public static List<IFileContentResultBean> findEqualFilesWithSameContent(final File dirToSearch) { final List<IFileContentResultBean> equalFiles = new ArrayList<IFileContentResultBean>(); final List<File> allFiles = FileSearchExtensions.findFilesRecursive(dirToSearch, "*"); for (int i = 0; i < allFiles.size(); i++) { final File toCompare = allFiles.get(i); for (int j = 0; j < allFiles.size(); j++) { final File file = allFiles.get(j); if (toCompare.equals(file)) { continue; } final IFileContentResultBean contentResultBean = CompareFileExtensions .compareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(contentResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(contentResultBean)) { equalFiles.add(contentResultBean); } } } return equalFiles; }
java
public static List<IFileContentResultBean> findEqualFilesWithSameContent(final File dirToSearch) { final List<IFileContentResultBean> equalFiles = new ArrayList<IFileContentResultBean>(); final List<File> allFiles = FileSearchExtensions.findFilesRecursive(dirToSearch, "*"); for (int i = 0; i < allFiles.size(); i++) { final File toCompare = allFiles.get(i); for (int j = 0; j < allFiles.size(); j++) { final File file = allFiles.get(j); if (toCompare.equals(file)) { continue; } final IFileContentResultBean contentResultBean = CompareFileExtensions .compareFiles(toCompare, file); final boolean equal = CompareFileExtensions.validateEquality(contentResultBean); // if equal is true and the list does not contain the same // compareResultBean then add it. if (equal && !equalFiles.contains(contentResultBean)) { equalFiles.add(contentResultBean); } } } return equalFiles; }
[ "public", "static", "List", "<", "IFileContentResultBean", ">", "findEqualFilesWithSameContent", "(", "final", "File", "dirToSearch", ")", "{", "final", "List", "<", "IFileContentResultBean", ">", "equalFiles", "=", "new", "ArrayList", "<", "IFileContentResultBean", ">", "(", ")", ";", "final", "List", "<", "File", ">", "allFiles", "=", "FileSearchExtensions", ".", "findFilesRecursive", "(", "dirToSearch", ",", "\"*\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "allFiles", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "File", "toCompare", "=", "allFiles", ".", "get", "(", "i", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "allFiles", ".", "size", "(", ")", ";", "j", "++", ")", "{", "final", "File", "file", "=", "allFiles", ".", "get", "(", "j", ")", ";", "if", "(", "toCompare", ".", "equals", "(", "file", ")", ")", "{", "continue", ";", "}", "final", "IFileContentResultBean", "contentResultBean", "=", "CompareFileExtensions", ".", "compareFiles", "(", "toCompare", ",", "file", ")", ";", "final", "boolean", "equal", "=", "CompareFileExtensions", ".", "validateEquality", "(", "contentResultBean", ")", ";", "// if equal is true and the list does not contain the same", "// compareResultBean then add it.", "if", "(", "equal", "&&", "!", "equalFiles", ".", "contains", "(", "contentResultBean", ")", ")", "{", "equalFiles", ".", "add", "(", "contentResultBean", ")", ";", "}", "}", "}", "return", "equalFiles", ";", "}" ]
Compare files with the same content. @param dirToSearch the dir to search @return the list with the result beans
[ "Compare", "files", "with", "the", "same", "content", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L678-L707
153,293
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.simpleCompareFiles
public static IFileCompareResultBean simpleCompareFiles(final File sourceFile, final File fileToCompare) { return compareFiles(sourceFile, fileToCompare, true, false, false, true, false); }
java
public static IFileCompareResultBean simpleCompareFiles(final File sourceFile, final File fileToCompare) { return compareFiles(sourceFile, fileToCompare, true, false, false, true, false); }
[ "public", "static", "IFileCompareResultBean", "simpleCompareFiles", "(", "final", "File", "sourceFile", ",", "final", "File", "fileToCompare", ")", "{", "return", "compareFiles", "(", "sourceFile", ",", "fileToCompare", ",", "true", ",", "false", ",", "false", ",", "true", ",", "false", ")", ";", "}" ]
Simple comparing the given files. @param sourceFile the source file @param fileToCompare the file to compare @return Returns a FileCompareResultBean Object with the results.
[ "Simple", "comparing", "the", "given", "files", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L872-L876
153,294
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.validateEquality
public static boolean validateEquality(final IFileCompareResultBean fileCompareResultBean) { return fileCompareResultBean.getFileExtensionEquality() && fileCompareResultBean.getLengthEquality() && fileCompareResultBean.getLastModifiedEquality() && fileCompareResultBean.getNameEquality(); }
java
public static boolean validateEquality(final IFileCompareResultBean fileCompareResultBean) { return fileCompareResultBean.getFileExtensionEquality() && fileCompareResultBean.getLengthEquality() && fileCompareResultBean.getLastModifiedEquality() && fileCompareResultBean.getNameEquality(); }
[ "public", "static", "boolean", "validateEquality", "(", "final", "IFileCompareResultBean", "fileCompareResultBean", ")", "{", "return", "fileCompareResultBean", ".", "getFileExtensionEquality", "(", ")", "&&", "fileCompareResultBean", ".", "getLengthEquality", "(", ")", "&&", "fileCompareResultBean", ".", "getLastModifiedEquality", "(", ")", "&&", "fileCompareResultBean", ".", "getNameEquality", "(", ")", ";", "}" ]
Validates the files encapsulated in the IFileCompareResultBean for simple equality. This means like if they have equal file extension, length, last modified, and filenames. @param fileCompareResultBean the FileCompareResultBean. @return true, if successful
[ "Validates", "the", "files", "encapsulated", "in", "the", "IFileCompareResultBean", "for", "simple", "equality", ".", "This", "means", "like", "if", "they", "have", "equal", "file", "extension", "length", "last", "modified", "and", "filenames", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L887-L893
153,295
lightblueseas/file-worker
src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java
CompareFileExtensions.validateEquality
public static boolean validateEquality(final IFileContentResultBean fileContentResultBean) { return fileContentResultBean.getFileExtensionEquality() && fileContentResultBean.getLengthEquality() && fileContentResultBean.getLastModifiedEquality() && fileContentResultBean.getNameEquality() && fileContentResultBean.getContentEquality(); }
java
public static boolean validateEquality(final IFileContentResultBean fileContentResultBean) { return fileContentResultBean.getFileExtensionEquality() && fileContentResultBean.getLengthEquality() && fileContentResultBean.getLastModifiedEquality() && fileContentResultBean.getNameEquality() && fileContentResultBean.getContentEquality(); }
[ "public", "static", "boolean", "validateEquality", "(", "final", "IFileContentResultBean", "fileContentResultBean", ")", "{", "return", "fileContentResultBean", ".", "getFileExtensionEquality", "(", ")", "&&", "fileContentResultBean", ".", "getLengthEquality", "(", ")", "&&", "fileContentResultBean", ".", "getLastModifiedEquality", "(", ")", "&&", "fileContentResultBean", ".", "getNameEquality", "(", ")", "&&", "fileContentResultBean", ".", "getContentEquality", "(", ")", ";", "}" ]
Validates the files encapsulated in the IFileCompareResultBean for total equality. This means like if they have equal file extension, length, last modified, filenames and content. @param fileContentResultBean the IFileContentResultBean. @return true, if successful
[ "Validates", "the", "files", "encapsulated", "in", "the", "IFileCompareResultBean", "for", "total", "equality", ".", "This", "means", "like", "if", "they", "have", "equal", "file", "extension", "length", "last", "modified", "filenames", "and", "content", "." ]
2c81de10fb5d68de64c1abc3ed64ca681ce76da8
https://github.com/lightblueseas/file-worker/blob/2c81de10fb5d68de64c1abc3ed64ca681ce76da8/src/main/java/de/alpharogroup/file/compare/CompareFileExtensions.java#L904-L911
153,296
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java
ESigList.canSign
public boolean canSign(boolean selectedOnly) { for (ESigItem item : items) { if ((!selectedOnly || item.isSelected()) && (item.getSignState() != SignState.FORCED_NO)) { return true; } } return false; }
java
public boolean canSign(boolean selectedOnly) { for (ESigItem item : items) { if ((!selectedOnly || item.isSelected()) && (item.getSignState() != SignState.FORCED_NO)) { return true; } } return false; }
[ "public", "boolean", "canSign", "(", "boolean", "selectedOnly", ")", "{", "for", "(", "ESigItem", "item", ":", "items", ")", "{", "if", "(", "(", "!", "selectedOnly", "||", "item", ".", "isSelected", "(", ")", ")", "&&", "(", "item", ".", "getSignState", "(", ")", "!=", "SignState", ".", "FORCED_NO", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if items exist that the user may sign. @param selectedOnly If true, examine only selected items. @return True if items exist that the user may sign.
[ "Returns", "true", "if", "items", "exist", "that", "the", "user", "may", "sign", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L50-L58
153,297
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java
ESigList.getCount
public int getCount(IESigType eSigType) { int result = 0; for (ESigItem item : items) { if (item.getESigType().equals(eSigType)) { result++; } } return result; }
java
public int getCount(IESigType eSigType) { int result = 0; for (ESigItem item : items) { if (item.getESigType().equals(eSigType)) { result++; } } return result; }
[ "public", "int", "getCount", "(", "IESigType", "eSigType", ")", "{", "int", "result", "=", "0", ";", "for", "(", "ESigItem", "item", ":", "items", ")", "{", "if", "(", "item", ".", "getESigType", "(", ")", ".", "equals", "(", "eSigType", ")", ")", "{", "result", "++", ";", "}", "}", "return", "result", ";", "}" ]
Returns the count of items of the specified type. @param eSigType The esignature type. @return Count of items of specified type.
[ "Returns", "the", "count", "of", "items", "of", "the", "specified", "type", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L75-L85
153,298
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java
ESigList.indexOf
public int indexOf(IESigType eSigType, String id) { return items.indexOf(new ESigItem(eSigType, id)); }
java
public int indexOf(IESigType eSigType, String id) { return items.indexOf(new ESigItem(eSigType, id)); }
[ "public", "int", "indexOf", "(", "IESigType", "eSigType", ",", "String", "id", ")", "{", "return", "items", ".", "indexOf", "(", "new", "ESigItem", "(", "eSigType", ",", "id", ")", ")", ";", "}" ]
Returns the index of a sig item identified by type and id. @param eSigType The esignature type. @param id The item id. @return Index of item.
[ "Returns", "the", "index", "of", "a", "sig", "item", "identified", "by", "type", "and", "id", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L94-L96
153,299
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java
ESigList.get
public ESigItem get(IESigType eSigType, String id) { int i = indexOf(eSigType, id); return i == -1 ? null : items.get(i); }
java
public ESigItem get(IESigType eSigType, String id) { int i = indexOf(eSigType, id); return i == -1 ? null : items.get(i); }
[ "public", "ESigItem", "get", "(", "IESigType", "eSigType", ",", "String", "id", ")", "{", "int", "i", "=", "indexOf", "(", "eSigType", ",", "id", ")", ";", "return", "i", "==", "-", "1", "?", "null", ":", "items", ".", "get", "(", "i", ")", ";", "}" ]
Returns a sig item identified by type and id, or null if not found. @param eSigType The esignature type. @param id The item id. @return Sig item.
[ "Returns", "a", "sig", "item", "identified", "by", "type", "and", "id", "or", "null", "if", "not", "found", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigList.java#L105-L108