id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
1644585_8 | public String getName() {
return name;
} |
1644585_9 | public String getValue() {
return value;
} |
1645877_0 | public InputStream getInputStream() {
try {
if (logger.isInfoEnabled())
logger.info("loading stream " + getResourceName());
return new FileInputStream(new File(path));
} catch (FileNotFoundException e) {
throw new RuntimeException("File for " + resourceName + " not found", e);
}
} |
1645877_1 | public InputStream getInputStream() {
try {
if (logger.isInfoEnabled())
logger.info("loading stream " + getResourceName());
return new FileInputStream(new File(path));
} catch (FileNotFoundException e) {
throw new RuntimeException("File for " + resourceName + " not found", e);
}
} |
1645877_2 | public DataSource parse(String url) {
if (url.startsWith("classpath://")) {
String path = url.replaceAll("classpath://", "");
return DataSourceFactory.classPathDataSource(path);
}
if (url.startsWith("file://")) {
String path = url.replaceAll("file://", "");
return DataSourceFactory.fileSystemDataSource(path);
}
if (url.startsWith("http://")) {
return DataSourceFactory.remoteDataSource(url);
}
// try each base location: classpath, filesystem, etc, instead returning default?
return dataSourceProvider.get(url);
} |
1645877_3 | public DataSource parse(String url) {
if (url.startsWith("classpath://")) {
String path = url.replaceAll("classpath://", "");
return DataSourceFactory.classPathDataSource(path);
}
if (url.startsWith("file://")) {
String path = url.replaceAll("file://", "");
return DataSourceFactory.fileSystemDataSource(path);
}
if (url.startsWith("http://")) {
return DataSourceFactory.remoteDataSource(url);
}
// try each base location: classpath, filesystem, etc, instead returning default?
return dataSourceProvider.get(url);
} |
1645877_4 | public DataSource parse(String url) {
if (url.startsWith("classpath://")) {
String path = url.replaceAll("classpath://", "");
return DataSourceFactory.classPathDataSource(path);
}
if (url.startsWith("file://")) {
String path = url.replaceAll("file://", "");
return DataSourceFactory.fileSystemDataSource(path);
}
if (url.startsWith("http://")) {
return DataSourceFactory.remoteDataSource(url);
}
// try each base location: classpath, filesystem, etc, instead returning default?
return dataSourceProvider.get(url);
} |
1645877_5 | public DataSource parse(String url) {
if (url.startsWith("classpath://")) {
String path = url.replaceAll("classpath://", "");
return DataSourceFactory.classPathDataSource(path);
}
if (url.startsWith("file://")) {
String path = url.replaceAll("file://", "");
return DataSourceFactory.fileSystemDataSource(path);
}
if (url.startsWith("http://")) {
return DataSourceFactory.remoteDataSource(url);
}
// try each base location: classpath, filesystem, etc, instead returning default?
return dataSourceProvider.get(url);
} |
1645877_6 | @Override
public InputStream getInputStream() {
if (logger.isInfoEnabled())
logger.info("returning static input stream " + getResourceName());
return inputStream;
} |
1645877_7 | @Override
public String getResourceName() {
return resourceName;
} |
1645877_8 | public void load() {
if (!isLoaded())
data = dataLoader.load();
} |
1645877_9 | public T get() {
if (!isLoaded())
load();
return data;
} |
1658141_0 | public String addContact(Contact contact) {
String id = idGenerator.newId();
// Como el servicio de generación de ids puede proporcionar
// ids repetidos, se debe comprobar si el id ya fue asignado.
// Se podría implementar una lógica de reintentos, pero finalmente
// decidimos que es mejor informar del error y que sean los
// clientes los encargados de decidir la politica de reintentos.
if(addressBookMap.get(id) != null) {
throw new InvalidIdException();
}
contact.setId(id);
addressBookMap.put(id, contact);
return id;
} |
1658141_1 | public String addContact(Contact contact) {
String id = idGenerator.newId();
// Como el servicio de generación de ids puede proporcionar
// ids repetidos, se debe comprobar si el id ya fue asignado.
// Se podría implementar una lógica de reintentos, pero finalmente
// decidimos que es mejor informar del error y que sean los
// clientes los encargados de decidir la politica de reintentos.
if(addressBookMap.get(id) != null) {
throw new InvalidIdException();
}
contact.setId(id);
addressBookMap.put(id, contact);
return id;
} |
1658141_2 | public Contact getContact(String contactId) {
Contact result = addressBookMap.get(contactId);
if(result == null) {
throw new InvalidIdException();
}
return result;
} |
1658141_3 | public Contact getContact(String contactId) {
Contact result = addressBookMap.get(contactId);
if(result == null) {
throw new InvalidIdException();
}
return result;
} |
1658141_4 | @Override
public String addContact(Contact contact) {
String id = idGenerator.newId();
// Como el servicio de generación de ids puede proporcionar
// ids repetidos, se debe comprobar si el id ya fue asignado.
// Se podría implementar una lógica de reintentos, pero finalmente
// decidimos que es mejor informar del error y que sean los
// clientes los encargados de decidir la politica de reintentos.
if(addressBookMap.get(id) != null) {
throw new InvalidIdException();
}
contact.setId(id);
addressBookMap.put(id, contact);
return id;
} |
1658141_5 | @Override
public Contact getContact(String contactId) {
Contact result = addressBookMap.get(contactId);
if(result == null) {
throw new InvalidIdException();
}
return result;
} |
1658141_6 | @Override
public Contact getContact(String contactId) {
Contact result = addressBookMap.get(contactId);
if(result == null) {
throw new InvalidIdException();
}
return result;
} |
1658141_7 | @Override
public String addContact(Contact contact) {
/* if (contact.getFirstName() == null || contact.getFirstName().trim().length() < 1) {
throw new InvalidContactException();
}
contact.setFirstName(contact.getFirstName().trim());
if (contact.getSurname() != null) {
contact.setSurname(contact.getSurname().trim());
}
if (checkDuplicate(contact)) {
throw new InvalidContactException();
}
*/
return addressBookDao.addContact(contact);
} |
1658141_8 | @Override
public String addContact(Contact contact) {
/* if (contact.getFirstName() == null || contact.getFirstName().trim().length() < 1) {
throw new InvalidContactException();
}
contact.setFirstName(contact.getFirstName().trim());
if (contact.getSurname() != null) {
contact.setSurname(contact.getSurname().trim());
}
if (checkDuplicate(contact)) {
throw new InvalidContactException();
}
*/
return addressBookDao.addContact(contact);
} |
1658141_9 | @Override
public String addContact(Contact contact) {
/* if (contact.getFirstName() == null || contact.getFirstName().trim().length() < 1) {
throw new InvalidContactException();
}
contact.setFirstName(contact.getFirstName().trim());
if (contact.getSurname() != null) {
contact.setSurname(contact.getSurname().trim());
}
if (checkDuplicate(contact)) {
throw new InvalidContactException();
}
*/
return addressBookDao.addContact(contact);
} |
1660918_0 | public static String shellifyOptionName(String name)
{
return Commands.shellifyOptionName(name);
} |
1660918_1 | public static String shellifyOptionNameDashed(String name)
{
return Commands.shellifyOptionNameDashed(name);
} |
1660918_2 | public static String shellifyOptionNameDashed(String name)
{
return Commands.shellifyOptionNameDashed(name);
} |
1660918_3 | public static String shellifyOptionNameDashed(String name)
{
return Commands.shellifyOptionNameDashed(name);
} |
1660918_4 | public static String shellifyOptionNameDashed(String name)
{
return Commands.shellifyOptionNameDashed(name);
} |
1660918_5 | public static String shellifyOptionNameDashed(String name)
{
return Commands.shellifyOptionNameDashed(name);
} |
1660918_6 | @Deprecated
public void write(Model project, Document document, OutputStream stream) throws java.io.IOException
{
updateModel(project, "project", new Counter(0), document.getRootElement());
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat().setIndent(" ").setLineSeparator(LS));
outputter.output(document, stream);
} |
1660918_7 | @Deprecated
public void write(Model project, Document document, OutputStream stream) throws java.io.IOException
{
updateModel(project, "project", new Counter(0), document.getRootElement());
XMLOutputter outputter = new XMLOutputter();
outputter.setFormat(Format.getPrettyFormat().setIndent(" ").setLineSeparator(LS));
outputter.output(document, stream);
} |
1660918_8 | @Override
public Set<Dependency> resolveDependencies(DependencyQuery query)
{
Set<Dependency> result = new HashSet<>();
Predicate<Dependency> filter = query.getDependencyFilter();
RepositorySystem system = container.getRepositorySystem();
Settings settings = container.getSettings();
DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());
List<RemoteRepository> remoteRepos = MavenConvertUtils.convertToMavenRepos(query.getDependencyRepositories(),
settings);
remoteRepos.addAll(MavenRepositories.getRemoteRepositories(container, settings));
CollectRequest collectRequest = new CollectRequest(new org.eclipse.aether.graph.Dependency(queryArtifact,
query.getScopeType()), remoteRepos);
DependencyRequest request = new DependencyRequest(collectRequest, null);
DependencyResult artifacts;
try
{
artifacts = system.resolveDependencies(session, request);
}
catch (NullPointerException e)
{
throw new RuntimeException("Could not resolve dependencies from Query [" + query
+ "] due to underlying exception", e);
}
catch (DependencyResolutionException e)
{
throw new RuntimeException(e);
}
DependencyNode root = artifacts.getRoot();
ResourceFactory factory = getResourceFactory();
for (DependencyNode node : root.getChildren())
{
Dependency d = MavenConvertUtils.convertToDependency(factory, node);
if (filter == null || filter.accept(d))
{
result.add(d);
}
}
return result;
} |
1660918_9 | @Override
public Set<Dependency> resolveDependencies(DependencyQuery query)
{
Set<Dependency> result = new HashSet<>();
Predicate<Dependency> filter = query.getDependencyFilter();
RepositorySystem system = container.getRepositorySystem();
Settings settings = container.getSettings();
DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate());
List<RemoteRepository> remoteRepos = MavenConvertUtils.convertToMavenRepos(query.getDependencyRepositories(),
settings);
remoteRepos.addAll(MavenRepositories.getRemoteRepositories(container, settings));
CollectRequest collectRequest = new CollectRequest(new org.eclipse.aether.graph.Dependency(queryArtifact,
query.getScopeType()), remoteRepos);
DependencyRequest request = new DependencyRequest(collectRequest, null);
DependencyResult artifacts;
try
{
artifacts = system.resolveDependencies(session, request);
}
catch (NullPointerException e)
{
throw new RuntimeException("Could not resolve dependencies from Query [" + query
+ "] due to underlying exception", e);
}
catch (DependencyResolutionException e)
{
throw new RuntimeException(e);
}
DependencyNode root = artifacts.getRoot();
ResourceFactory factory = getResourceFactory();
for (DependencyNode node : root.getChildren())
{
Dependency d = MavenConvertUtils.convertToDependency(factory, node);
if (filter == null || filter.accept(d))
{
result.add(d);
}
}
return result;
} |
1666060_0 | static Subscriber instantiateSubscriber(EPServiceProvider epService, SubscriberConfig subscriberConfig)
throws InstantiationException, IllegalAccessException, InvocationTargetException
{
// The Esper runtime engine requires event names
if (subscriberConfig.getEventOutputName() == null) {
throw new IllegalStateException("Esper topic key not specified!");
}
Class subscriberKlass;
try {
// Find the subscriber class
String subscriberKlassName = subscriberConfig.getType();
subscriberKlass = Class.forName(subscriberKlassName);
}
catch (ClassNotFoundException e) {
throw new IllegalStateException("Class not found for: " + subscriberConfig.getType());
}
// Find the subscriber constructor
// We expect subscriber to have a constructor with 2 arguments (SubscriberConfig, EPServiceProvider)
Constructor<?> constructor = null;
Class subscriberConfigKlass = null;
for (Constructor<?> cstr : subscriberKlass.getConstructors()) {
if (cstr.getParameterTypes().length == 2) {
constructor = cstr;
subscriberConfigKlass = cstr.getParameterTypes()[0];
}
}
if (constructor != null && subscriberConfigKlass != null) {
// Make sure to downcast configuration objects
if (subscriberConfig.isEnabled()) {
return (Subscriber) constructor.newInstance(subscriberConfigKlass.cast(subscriberConfig), epService);
}
else {
log.info("Skipping disabled subscriber: " + subscriberConfig.getName());
return null;
}
}
else {
throw new IllegalArgumentException("Can't find a suitable constructor in subscribers class " + subscriberKlass);
}
} |
1666060_1 | @VisibleForTesting
static UpdateListener instantiateUpdateListener(final PublisherConfig publisherConfig)
throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException
{
final String listenerType = publisherConfig.getType();
final Class listenerClass = Class.forName(listenerType);
Constructor<?> defaultConstructor = null;
Constructor<?> configConstructor = null;
for (final Constructor<?> constructor : listenerClass.getConstructors()) {
if (constructor.getParameterTypes() == null || constructor.getParameterTypes().length == 0) {
defaultConstructor = constructor;
}
else if (constructor.getParameterTypes().length == 1) {
configConstructor = constructor;
}
}
final UpdateListener listener;
if (configConstructor != null) {
final Class listenerConfigClass = configConstructor.getParameterTypes()[0];
listener = (UpdateListener) configConstructor.newInstance(listenerConfigClass.cast(publisherConfig));
}
else if (defaultConstructor != null) {
listener = (UpdateListener) defaultConstructor.newInstance();
}
else {
throw new IllegalArgumentException("Can't find a suitable constructor in subscribers class " + listenerClass.getName());
}
return listener;
} |
1666060_2 | public double getAlpha()
{
return alpha;
} |
1670551_0 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_1 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_2 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_3 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_4 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_5 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_6 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_7 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_8 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1670551_9 | @Override
public Query parse(final String query, final String defaultField) throws QueryNodeException {
try {
return (Query) super.parse(query, defaultField);
}
catch (final QueryNodeException e) {
throw new ParseException("Query parsing failed", e);
}
} |
1672467_0 | public static List<String> utf8byteSizeSplit(String s, int maxChunkBytes) {
if (maxChunkBytes < 6) {
throw new IllegalArgumentException("Max UTF-8 chunk size cannot be less than 6");
}
byte[] bytes = s.getBytes(UTF8);
List<String> result = new ArrayList<String>();
int chunkStartOffset = 0;
int chunkLength = 0;
for (byte b : bytes) {
if (chunkLength + utf8CharBytes(b) > maxChunkBytes) {
// add chunk to result
result.add(new String(bytes, chunkStartOffset, chunkLength, UTF8));
// init next chunk
chunkStartOffset += chunkLength;
chunkLength = 0;
}
// add byte to current chunk
chunkLength++;
}
if (chunkLength > 0) {
result.add(new String(bytes, chunkStartOffset, chunkLength, UTF8));
}
return result;
} |
1676303_0 | public final boolean isNetworkError() {
return (getCause() != null) ? getCause() instanceof IOException : false;
} |
1676303_1 | public List<OffendingRule> getOffendingRules() {
return offendingRules;
} |
1676303_2 | public List<OffendingRule> getOffendingRules() {
return offendingRules;
} |
1676303_3 | public boolean matches(final Rule rule) {
return rule != null
&& ((offendingRule.getValue() == null && rule.getValue() == null) || (offendingRule.getValue()
.equals(rule.getValue())));
} |
1676303_4 | public boolean matches(final Rule rule) {
return rule != null
&& ((offendingRule.getValue() == null && rule.getValue() == null) || (offendingRule.getValue()
.equals(rule.getValue())));
} |
1676303_5 | @Override
public String toString() {
/*
* Outputs a json like the one gnip expects.
*
* You might say WTF, we are crafting the json string by hand.
* Thats because its just a toString method, and because i don't
* want extra dependencies.
*/
final StringBuilder sb = new StringBuilder();
sb.append('{');
if(tag != null) {
sb.append("\"tag\": \"");
sb.append(escape(tag));
sb.append('"');
}
if(value != null) {
if(sb.length() != 0) {
if(sb.length() > 1) {
sb.append(", ");
}
}
sb.append("\"value\": \"");
sb.append(escape(value));
sb.append('"');
}
if(id != null) {
if(sb.length() != 0) {
if(sb.length() > 1) {
sb.append(", ");
}
}
sb.append("\"id\": ");
sb.append(id);
}
sb.append('}');
return sb.toString();
} |
1676303_6 | @Override
public String toString() {
/*
* Outputs a json like the one gnip expects.
*
* You might say WTF, we are crafting the json string by hand.
* Thats because its just a toString method, and because i don't
* want extra dependencies.
*/
final StringBuilder sb = new StringBuilder();
sb.append('{');
if(tag != null) {
sb.append("\"tag\": \"");
sb.append(escape(tag));
sb.append('"');
}
if(value != null) {
if(sb.length() != 0) {
if(sb.length() > 1) {
sb.append(", ");
}
}
sb.append("\"value\": \"");
sb.append(escape(value));
sb.append('"');
}
if(id != null) {
if(sb.length() != 0) {
if(sb.length() > 1) {
sb.append(", ");
}
}
sb.append("\"id\": ");
sb.append(id);
}
sb.append('}');
return sb.toString();
} |
1676303_7 | @Override
public boolean equals(final java.lang.Object obj) {
boolean ret = false;
if(this == obj) {
ret = true;
} else if(obj instanceof Rule) {
final Rule r = ((Rule)obj);
ret = Objects.equals(value, r.value)
&& Objects.equals(tag, r.tag)
&& Objects.equals(id, r.id)
;
}
return ret;
} |
1676303_8 | @Override
public URI createStreamUri(final String account, final String streamName, final Integer backfill) {
if (account == null || account.trim().isEmpty()) {
throw new IllegalArgumentException("The account cannot be null or empty");
}
if (streamName == null || streamName.trim().isEmpty()) {
throw new IllegalArgumentException("The streamName cannot be null or empty");
}
if(backfill != null) {
throw new IllegalArgumentException("Backfill is not supported at the compliance");
}
return URI.create(String.format(Locale.ENGLISH, BASE_GNIP_STREAM_URI_V2, account.trim(), streamName.trim(), partition));
} |
1676303_9 | @Override
public final Activity unmarshall(final String s) {
try {
return mapper.readValue(s, ComplianceActivity.class).toActivity();
} catch (final IOException | UncheckedIOException e) {
logger.warn("Failed to parse compliance activity: " + s, e);
return null;
}
} |
1688262_0 | public ShapedRecipe(RecipeBuilder builder) {
super(builder.result, builder.plugin, builder.includeData);
this.rows = builder.rows;
this.ingredientsMap = builder.ingredientsMap;
} |
1688262_1 | public ShapelessRecipe(RecipeBuilder builder) {
super(builder.result, builder.plugin, builder.includeData);
this.ingredients = builder.ingredients;
} |
1688262_2 | public RecipeBuilder clone(Recipe recipe) {
plugin = recipe.getPlugin();
result = recipe.getResult();
ingredients = recipe.getIngredients();
if (recipe instanceof ShapedRecipe) {
ShapedRecipe shaped = (ShapedRecipe) recipe;
this.ingredientsMap = shaped.getIngredientsMap();
rows.addAll(shaped.getRows());
} else if (recipe instanceof ShapelessRecipe) {
// if needed
}
return this;
} |
1688262_3 | @Override
public int size() {
return getContents().length;
} |
1688262_4 | public boolean contains(Material material, int amount) {
return getAmount(material) >= amount;
} |
1688262_5 | public void add(int firstSlot, int lastSlot, ItemStack item) {
//First pass try to add to existing stacks, second pass, add to empty slots
final boolean reversed = lastSlot < firstSlot;
final int incr = reversed ? -1 : 1;
for (int pass = 0; pass < 2; pass++) {
for (int index = firstSlot; reversed ? (index >= lastSlot) : (index <= lastSlot); index += incr) {
ItemStack slot = get(index);
if (pass == 1) {
if (slot == null) {
set(index, item);
item.setAmount(0);
return;
}
}
if (slot != null && slot.equalsIgnoreSize(item)) {
slot.stack(item);
set(index, slot);
}
if (item.isEmpty()) {
return;
}
}
}
} |
1688262_6 | @Override
public boolean remove(Object o) {
for (int i = 0; i < contents.length; i++) {
ItemStack item = get(i);
if (item == null) {
continue;
}
if (item.equals(o) || item.getMaterial().equals(o)) {
set(i, null);
return true;
}
}
return false;
} |
1688262_7 | @Override
public boolean addAll(Collection<? extends ItemStack> items) {
Iterator<? extends ItemStack> i = items.iterator();
while (i.hasNext()) {
ItemStack next = i.next();
if (next == null) {
continue;
}
add(next);
}
return true;
} |
1688262_8 | @Override
public boolean removeAll(Collection<?> objects) {
Iterator<?> iter = objects.iterator();
while (iter.hasNext()) {
Object o = iter.next();
for (int i = 0; i < size(); i++) {
ItemStack item = get(i);
if (item == null) {
continue;
}
if (o instanceof ItemStack && ((ItemStack) o).equalsIgnoreSize(item)) {
set(i, null);
} else if (o instanceof Material && ((Material) o).equals(item.getMaterial())) {
set(i, null);
}
}
}
return true;
} |
1688262_9 | @Override
public boolean retainAll(Collection<?> objects) {
for (ItemStack item : getContents()) {
if (item == null) {
continue;
}
if (!objects.contains(item)) {
remove(item);
}
}
return true;
} |
1691340_0 | static IMenuService getSubMenuService(Map<String, IMenuService> menuMap) {
int length = menuMap.size();
if (length == 0) return null;
Iterator<IMenuService> it = menuMap.values().iterator();
IMenuService sub = null;
while (it.hasNext()) {
if (length == 1) return it.next();
IMenuService temp = it.next();
Class<? extends IMenuService> clazz = null;
if (sub == null) {
clazz = IMenuService.class;
} else {
clazz = sub.getClass();
}
if (clazz.isAssignableFrom(temp.getClass())) {
sub = temp;
}
}
return sub;
} |
1691340_1 | public static String getMenusJson(String id, int level) {
IMenuService menuService = getMenuService();
List<? extends IMenu> menus = null;
if (menuService != null) {
menus = menuService.getMenus(id, level);
} else {
menus = getAllModulesDefaultMenu();
}
return convert(menus);
} |
1691340_2 | public static ApplicationContext getApplicationContext() {
return getAc();
} |
1691340_3 | public static Resource[] getStrutsConfigResources() {
List<Resource> resourcesList = new ArrayList<Resource>(16);
Enumeration<ModulePluginDriverInfo> dirverInfos = getDriverInfos();
SystemLogUtils.rootPrintln("Struts Config 配置文件Find Begin!");
while (dirverInfos.hasMoreElements()) {
ModulePluginDriverInfo driverInfo = dirverInfos.nextElement();
if (!(driverInfo.getDriver() instanceof IStrutsSupport)) continue;
SystemLogUtils.secondPrintln(driverInfo.getDriver() + "Struts Config 配置文件Find!");
List<Resource> list = getStrutsConfigResources(driverInfo);
resourcesList.addAll(list);
SystemLogUtils.thirdPrintln(driverInfo.getDriver() + "找到(" + list.size() + ")个配置文件!");
}
SystemLogUtils.rootPrintln("Struts Config 配置文件 Find End!");
return resourcesList.toArray(new Resource[resourcesList.size()]);
} |
1691340_4 | public static Resource[] getStrutsConfigResources() {
List<Resource> resourcesList = new ArrayList<Resource>(16);
Enumeration<ModulePluginDriverInfo> dirverInfos = getDriverInfos();
SystemLogUtils.rootPrintln("Struts Config 配置文件Find Begin!");
while (dirverInfos.hasMoreElements()) {
ModulePluginDriverInfo driverInfo = dirverInfos.nextElement();
if (!(driverInfo.getDriver() instanceof IStrutsSupport)) continue;
SystemLogUtils.secondPrintln(driverInfo.getDriver() + "Struts Config 配置文件Find!");
List<Resource> list = getStrutsConfigResources(driverInfo);
resourcesList.addAll(list);
SystemLogUtils.thirdPrintln(driverInfo.getDriver() + "找到(" + list.size() + ")个配置文件!");
}
SystemLogUtils.rootPrintln("Struts Config 配置文件 Find End!");
return resourcesList.toArray(new Resource[resourcesList.size()]);
} |
1691340_5 | public static Object invokeGetterMethod(Object obj, String propertyName) {
String getterMethodName = "get" + StringUtils.capitalize(propertyName);
return invokeMethod(obj, getterMethodName, new Class[]{}, new Object[]{});
} |
1691340_6 | public static Object getFieldValue(final Object obj, final String fieldName) {
if (obj == null || StringUtil.isEmpty(fieldName)) {
return null;
}
int index = fieldName.indexOf(".");
if (index < 0) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
}
Object result = null;
try {
result = field.get(obj);
} catch (IllegalAccessException e) {
log.error("不可能抛出的异常{}", e);
}
return result;
} else {
return getFieldValue(getFieldValue(obj, fieldName.substring(0, index)), fieldName.substring(index + 1));
}
} |
1691340_7 | public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
if (obj == null) {
throw new IllegalArgumentException("[" + obj + "]");
}
int index = fieldName.indexOf(".");
if (index < 0) {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
}
try {
field.set(obj, value);
} catch (IllegalAccessException e) {
log.error("不可能抛出的异常:{}", e);
}
} else {
setFieldValue(getFieldValue(obj, fieldName.substring(0, index)), fieldName.substring(index + 1), value);
}
} |
1691340_8 | public static Field getAccessibleField(final Object obj, final String fieldName) {
if (obj == null || StringUtil.isEmpty(fieldName)) {
return null;
}
int index = fieldName.indexOf(".");
if (index < 0) {
return getAccessibleField0(obj, fieldName);
} else {
return getAccessibleField(getFieldValue(obj, fieldName.substring(0, index)), fieldName.substring(index + 1));
}
} |
1691340_9 | public static Method getAccessibleMethod(final Object obj, final String methodName, final Class<?>... parameterTypes) {
if (obj == null) {
return null;
}
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Method method = superClass.getDeclaredMethod(methodName, parameterTypes);
method.setAccessible(true);
return method;
} catch (NoSuchMethodException e) {
if (superClass.getSuperclass() == Object.class) {
log.warn(e.toString() + "[" + superClass + "]", e);
}
// Method不在当前类定义,继续向上转型
}
}
return null;
} |
1707059_0 | protected static List<PathSegment> extractPathComponents(String path) {
List<PathSegment> components = new ArrayList<PathSegment>();
if (path != null) {
int inBrace = 0;
boolean definingRegexp = false;
StringBuilder name = new StringBuilder();
StringBuilder regexp = new StringBuilder();
for (int i = 0; i < path.length(); i++) {
char ch = path.charAt(i);
if (ch == '{') {
inBrace++;
}
else if (ch == '}') {
inBrace--;
if (inBrace == 0) {
definingRegexp = false;
}
}
else if (inBrace == 1 && ch == ':') {
definingRegexp = true;
continue;
}
if (definingRegexp) {
regexp.append(ch);
}
else if (!Character.isWhitespace(ch) && ch != '/') {
name.append(ch);
}
if (i + 1 == path.length() || (ch == '/' && !definingRegexp)) {
String trimmed = name.toString().trim();
if (!trimmed.isEmpty()) {
components.add(new PathSegment(trimmed, regexp.length() > 0 ? regexp.toString().trim() : null));
}
name = new StringBuilder();
regexp = new StringBuilder();
}
}
}
return components;
} |
1707059_1 | protected static List<PathSegment> extractPathComponents(String path) {
List<PathSegment> components = new ArrayList<PathSegment>();
if (path != null) {
StringBuilder value = new StringBuilder();
if (!path.startsWith("/")) {
value.append("/");//first path segment should always start with "/"
}
StringBuilder variable = new StringBuilder();
StringBuilder regexp = new StringBuilder();
int inBrace = 0;
boolean definingRegexp = false;
for (int i = 0; i < path.length(); i++) {
char ch = path.charAt(i);
if (ch == '{') {
inBrace++;
if (inBrace == 1) {
//outer brace defines new path segment
if (value.length() > 0) {
components.add(new PathSegment(value.toString(), variable.length() > 0 ? variable.toString() : null, regexp.length() > 0 ? regexp.toString() : null));
}
value = new StringBuilder();
variable = new StringBuilder();
regexp = new StringBuilder();
}
}
else if (ch == '}') {
inBrace--;
if (inBrace == 0) {
definingRegexp = false;
}
}
else if (inBrace == 1 && ch == ':') {
definingRegexp = true;
continue;
}
else if (!definingRegexp && !Character.isWhitespace(ch) && inBrace > 0) {
variable.append(ch);
}
if (definingRegexp) {
regexp.append(ch);
}
else if (!Character.isWhitespace(ch)) {
value.append(ch);
}
}
if (value.length() > 0) {
components.add(new PathSegment(value.toString(), variable.length() > 0 ? variable.toString() : null, regexp.length() > 0 ? regexp.toString() : null));
}
}
return components;
} |
1707059_2 | static List<String> getGroupsOnField(String groupsAsString) {
List<String> classes = new ArrayList<>();
final String validationGroupsPrefix = "groups()={";
int indexOfGroups = groupsAsString.indexOf(validationGroupsPrefix);
if (indexOfGroups == -1) {
return Collections.emptyList();
}
String tail = groupsAsString.substring(indexOfGroups);
int indexOfClosingBrace = tail.indexOf("}");
classes = addClasses(classes, tail.substring(validationGroupsPrefix.length(), indexOfClosingBrace));
return classes;
} |
1707059_3 | static List<String> getGroupsOnField(String groupsAsString) {
List<String> classes = new ArrayList<>();
final String validationGroupsPrefix = "groups()={";
int indexOfGroups = groupsAsString.indexOf(validationGroupsPrefix);
if (indexOfGroups == -1) {
return Collections.emptyList();
}
String tail = groupsAsString.substring(indexOfGroups);
int indexOfClosingBrace = tail.indexOf("}");
classes = addClasses(classes, tail.substring(validationGroupsPrefix.length(), indexOfClosingBrace));
return classes;
} |
1707059_4 | static List<String> getGroupsOnField(String groupsAsString) {
List<String> classes = new ArrayList<>();
final String validationGroupsPrefix = "groups()={";
int indexOfGroups = groupsAsString.indexOf(validationGroupsPrefix);
if (indexOfGroups == -1) {
return Collections.emptyList();
}
String tail = groupsAsString.substring(indexOfGroups);
int indexOfClosingBrace = tail.indexOf("}");
classes = addClasses(classes, tail.substring(validationGroupsPrefix.length(), indexOfClosingBrace));
return classes;
} |
1707059_5 | static List<String> getGroupsOnField(String groupsAsString) {
List<String> classes = new ArrayList<>();
final String validationGroupsPrefix = "groups()={";
int indexOfGroups = groupsAsString.indexOf(validationGroupsPrefix);
if (indexOfGroups == -1) {
return Collections.emptyList();
}
String tail = groupsAsString.substring(indexOfGroups);
int indexOfClosingBrace = tail.indexOf("}");
classes = addClasses(classes, tail.substring(validationGroupsPrefix.length(), indexOfClosingBrace));
return classes;
} |
1707059_6 | public static boolean hasMatchingValidationGroup(String targetGroups, AnnotationMirror annotationMirror) {
// get validationGroups from Enunciate config file, this holds the active validation groups (if any) in attribute
// "beanValidationGroups" of jackson module:
// e.g. <jackson disabled="false" beanValidationGroups="com.ifyouwannabecool.beanval.DataAPI"/>
List<String> activeValidationGroups = ValidationGroupHelper.getActiveValidationGroups(targetGroups);
if (annotationMirror != null) {
List<String> groupsOnField = getGroupsOnField(annotationMirror.getElementValues().toString());
if (runningWithDefaultGroupOnFieldInDefaultGroup(groupsOnField, activeValidationGroups)) {
return true;
}
if (validationGroupOnFieldMatchesWithActiveGroup(groupsOnField, activeValidationGroups)) {
return true;
}
}
return false;
} |
1707059_7 | public static boolean hasMatchingValidationGroup(String targetGroups, AnnotationMirror annotationMirror) {
// get validationGroups from Enunciate config file, this holds the active validation groups (if any) in attribute
// "beanValidationGroups" of jackson module:
// e.g. <jackson disabled="false" beanValidationGroups="com.ifyouwannabecool.beanval.DataAPI"/>
List<String> activeValidationGroups = ValidationGroupHelper.getActiveValidationGroups(targetGroups);
if (annotationMirror != null) {
List<String> groupsOnField = getGroupsOnField(annotationMirror.getElementValues().toString());
if (runningWithDefaultGroupOnFieldInDefaultGroup(groupsOnField, activeValidationGroups)) {
return true;
}
if (validationGroupOnFieldMatchesWithActiveGroup(groupsOnField, activeValidationGroups)) {
return true;
}
}
return false;
} |
1707059_8 | public static boolean hasMatchingValidationGroup(String targetGroups, AnnotationMirror annotationMirror) {
// get validationGroups from Enunciate config file, this holds the active validation groups (if any) in attribute
// "beanValidationGroups" of jackson module:
// e.g. <jackson disabled="false" beanValidationGroups="com.ifyouwannabecool.beanval.DataAPI"/>
List<String> activeValidationGroups = ValidationGroupHelper.getActiveValidationGroups(targetGroups);
if (annotationMirror != null) {
List<String> groupsOnField = getGroupsOnField(annotationMirror.getElementValues().toString());
if (runningWithDefaultGroupOnFieldInDefaultGroup(groupsOnField, activeValidationGroups)) {
return true;
}
if (validationGroupOnFieldMatchesWithActiveGroup(groupsOnField, activeValidationGroups)) {
return true;
}
}
return false;
} |
1707059_9 | public static boolean hasMatchingValidationGroup(String targetGroups, AnnotationMirror annotationMirror) {
// get validationGroups from Enunciate config file, this holds the active validation groups (if any) in attribute
// "beanValidationGroups" of jackson module:
// e.g. <jackson disabled="false" beanValidationGroups="com.ifyouwannabecool.beanval.DataAPI"/>
List<String> activeValidationGroups = ValidationGroupHelper.getActiveValidationGroups(targetGroups);
if (annotationMirror != null) {
List<String> groupsOnField = getGroupsOnField(annotationMirror.getElementValues().toString());
if (runningWithDefaultGroupOnFieldInDefaultGroup(groupsOnField, activeValidationGroups)) {
return true;
}
if (validationGroupOnFieldMatchesWithActiveGroup(groupsOnField, activeValidationGroups)) {
return true;
}
}
return false;
} |
1710792_0 | @Override
public String toString() {
final Hex hex = new Hex();
final byte[] bytes = new byte[getLength()];
System.arraycopy(getBytes(), 0, bytes, 0, bytes.length);
return new String(hex.encode(bytes));
} |
1710792_1 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1710792_2 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1710792_3 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1710792_4 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1710792_5 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1710792_6 | static BoxerUnboxer<?,? extends Writable> createOutputType(String type) {
if ("text".equals(type)) {
return new TextBoxerUnboxer();
}
else if ("long".equals(type)) {
return new LongBoxerUnboxer();
}
else if ("double".equals(type)) {
return new DoubleBoxerUnboxer();
}
else if ("json".equals(type)) {
return new JsonBoxerUnboxer();
}
else if ("bytes".equals(type)) {
return new BytesBoxerUnboxer();
}
return null;
} |
1711412_0 | public void setCompiler(Compiler compiler) {
this.compiler = compiler;
} |
1711412_1 | public void setCompiler(Compiler compiler) {
this.compiler = compiler;
} |
1711467_0 | protected void validate(List<TableInfo> tableInfos)
{
db = mongo.getDB(databaseName);
if (db == null)
{
logger.error("Database " + databaseName + "does not exist");
throw new SchemaGenerationException("database " + databaseName + "does not exist", "mongoDb", databaseName);
}
else
{
for (TableInfo tableInfo : tableInfos)
{
if (tableInfo.getLobColumnInfo().isEmpty())
{
if (!db.collectionExists(tableInfo.getTableName()))
{
logger.error("Collection " + tableInfo.getTableName() + "does not exist in db " + db.getName());
throw new SchemaGenerationException("Collection " + tableInfo.getTableName()
+ " does not exist in db " + db.getName(), "mongoDb", databaseName,
tableInfo.getTableName());
}
}
else
{
checkMultipleLobs(tableInfo);
if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES))
{
logger.error("Collection " + tableInfo.getTableName() + MongoDBUtils.FILES
+ "does not exist in db " + db.getName());
throw new SchemaGenerationException("Collection " + tableInfo.getTableName()
+ " does not exist in db " + db.getName(), "mongoDb", databaseName,
tableInfo.getTableName());
}
if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS))
{
logger.error("Collection " + tableInfo.getTableName() + MongoDBUtils.CHUNKS
+ "does not exist in db " + db.getName());
throw new SchemaGenerationException("Collection " + tableInfo.getTableName()
+ " does not exist in db " + db.getName(), "mongoDb", databaseName,
tableInfo.getTableName());
}
}
}
}
} |
1711467_1 | protected void update(List<TableInfo> tableInfos)
{
for (TableInfo tableInfo : tableInfos)
{
DBObject options = setCollectionProperties(tableInfo);
DB db = mongo.getDB(databaseName);
DBCollection collection = null;
if (tableInfo.getLobColumnInfo().isEmpty())
{
if (!db.collectionExists(tableInfo.getTableName()))
{
collection = db.createCollection(tableInfo.getTableName(), options);
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName(), showQuery);
}
collection = collection != null ? collection : db.getCollection(tableInfo.getTableName());
boolean isCappedCollection = isCappedCollection(tableInfo);
if (!isCappedCollection)
{
createIndexes(tableInfo, collection);
}
}
else
{
checkMultipleLobs(tableInfo);
if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES))
{
coll = db.createCollection(tableInfo.getTableName() + MongoDBUtils.FILES, options);
createUniqueIndexGFS(coll, tableInfo.getIdColumnName());
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.FILES,
showQuery);
}
if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS))
{
db.createCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS, options);
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.CHUNKS,
showQuery);
}
}
}
} |
1711467_2 | protected void create(List<TableInfo> tableInfos)
{
for (TableInfo tableInfo : tableInfos)
{
DBObject options = setCollectionProperties(tableInfo);
DB db = mongo.getDB(databaseName);
if (tableInfo.getLobColumnInfo().isEmpty())
{
if (db.collectionExists(tableInfo.getTableName()))
{
db.getCollection(tableInfo.getTableName()).drop();
KunderaCoreUtils.printQuery("Drop existing collection: " + tableInfo.getTableName(), showQuery);
}
DBCollection collection = db.createCollection(tableInfo.getTableName(), options);
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName(), showQuery);
boolean isCappedCollection = isCappedCollection(tableInfo);
if (!isCappedCollection)
{
createIndexes(tableInfo, collection);
}
}
else
{
/*
* In GridFS we have 2 collections. TABLE_NAME.chunks for
* storing chunks of data and TABLE_NAME.MongoDBUtils.FILES for
* storing it's metadata.
*/
checkMultipleLobs(tableInfo);
if (db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES))
{
db.getCollection(tableInfo.getTableName() + MongoDBUtils.FILES).drop();
KunderaCoreUtils.printQuery(
"Drop existing Grid FS Metadata collection: " + tableInfo.getTableName()
+ MongoDBUtils.FILES, showQuery);
}
if (db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS))
{
db.getCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS).drop();
KunderaCoreUtils.printQuery("Drop existing Grid FS data collection: " + tableInfo.getTableName()
+ MongoDBUtils.CHUNKS, showQuery);
}
coll = db.createCollection(tableInfo.getTableName() + MongoDBUtils.FILES, options);
createUniqueIndexGFS(coll, tableInfo.getIdColumnName());
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.FILES,
showQuery);
db.createCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS, options);
KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.CHUNKS,
showQuery);
}
}
} |
1711467_3 | public void dropSchema()
{
if (operation != null && operation.equalsIgnoreCase("create-drop"))
{
for (TableInfo tableInfo : tableInfos)
{
if (tableInfo.getLobColumnInfo().isEmpty())
{
coll = db.getCollection(tableInfo.getTableName());
coll.drop();
KunderaCoreUtils.printQuery("Drop collection:" + tableInfo.getTableName(), showQuery);
}
else
{
coll = db.getCollection(tableInfo.getTableName() + MongoDBUtils.FILES);
coll.drop();
KunderaCoreUtils.printQuery("Drop collection:" + tableInfo.getTableName() + MongoDBUtils.FILES,
showQuery);
coll = db.getCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS);
coll.drop();
KunderaCoreUtils.printQuery("Drop collection:" + tableInfo.getTableName() + MongoDBUtils.CHUNKS,
showQuery);
}
}
}
db = null;
} |
1711467_4 | public Properties getConnectionProperties()
{
return esmd != null ? esmd.getConnectionProperties() : null;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.