code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static Expression createExpression(String expression) {
try {
return INSTANCE.ctorExpression.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java |
public static Extractor createExtractor(String expression) {
try {
return INSTANCE.ctorExtractor.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java |
public static Updater createUpdater(String expression) {
try {
return INSTANCE.ctorUpdater.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java |
public static Condition createCondition(String expression) {
try {
return INSTANCE.ctorCondition.newInstance(expression);
}
catch (Exception e) {
throw new RuntimeException(e);
}
} | java |
protected Constructor getConstructor(Class type) {
try {
return type.getConstructor(String.class);
}
catch (NoSuchMethodException e) {
throw new RuntimeException(
"Unable to find a constructor that accepts"
+ " a single String argum... | java |
public static EngineeringObjectModelWrapper enhance(AdvancedModelWrapper model) {
if (!model.isEngineeringObject()) {
throw new IllegalArgumentException("The model of the AdvancedModelWrapper is no EngineeringObject");
}
return new EngineeringObjectModelWrapper(model.getUnderlyingMod... | java |
public List<Field> getForeignKeyFields() {
List<Field> fields = new ArrayList<Field>();
for (Field field : model.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
fields.add(field);
}
}
return fields;
... | java |
public AdvancedModelWrapper loadReferencedModel(Field field, ModelRegistry modelRegistry,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
try {
ModelDescription description = getModelDescriptionFromField(field);
String modelKey = (String) FieldUtils.readFi... | java |
private ModelDescription getModelDescriptionFromField(Field field) {
OpenEngSBForeignKey key = field.getAnnotation(OpenEngSBForeignKey.class);
ModelDescription description = new ModelDescription(key.modelType(), key.modelVersion());
return description;
} | java |
public synchronized Long generateId() {
if (sequenceBlock == null || !sequenceBlock.hasNext()) {
sequenceBlock = allocateSequenceBlock();
}
return sequenceBlock.next();
} | java |
private String performRemoveLeading(String source, Integer length, Matcher matcher) {
if (length != null && length != 0) {
matcher.region(0, length);
}
if (matcher.find()) {
String matched = matcher.group();
return source.substring(matched.length());
}... | java |
public void set( float radians )
{
float c = (float)StrictMath.cos( radians );
float s = (float)StrictMath.sin( radians );
m00 = c;
m01 = -s;
m10 = s;
m11 = c;
} | java |
protected DataType put(Class<?> clazz, int type, String name) {
DataType dataType = new DataType(type, name);
map.put(clazz, dataType);
return dataType;
} | java |
public static byte[] decrypt(byte[] text, Key key) throws DecryptionException {
return decrypt(text, key, key.getAlgorithm());
} | java |
public static byte[] decrypt(byte[] text, Key key, String algorithm) throws DecryptionException {
Cipher cipher;
try {
LOGGER.trace("start decrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.DECRYPT_MODE, key);
... | java |
public static byte[] encrypt(byte[] text, Key key) throws EncryptionException {
return encrypt(text, key, key.getAlgorithm());
} | java |
public static byte[] encrypt(byte[] text, Key key, String algorithm) throws EncryptionException {
Cipher cipher;
try {
LOGGER.trace("start encrypting text using {} cipher", algorithm);
cipher = Cipher.getInstance(algorithm);
cipher.init(Cipher.ENCRYPT_MODE, key);
... | java |
public static byte[] sign(byte[] text, PrivateKey key, String algorithm) throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initSign(key);
} catch (GeneralSecurityException e) {
throw new IllegalArgum... | java |
public static boolean verify(byte[] text, byte[] signatureValue, PublicKey key, String algorithm)
throws SignatureException {
Signature signature;
try {
signature = Signature.getInstance(algorithm);
signature.initVerify(key);
} catch (GeneralSecurityException e) {... | java |
protected synchronized Object getCompiledExpression() {
if (compiledExpression == null) {
try {
compiledExpression = Ognl.parseExpression(getExpression());
}
catch (OgnlException e) {
throw new IllegalArgumentException("[" + getExpression() + "... | java |
public static <T> T view(Object completeObject, T viewObject) {
if (completeObject == null) return null;
Map<String, PropertyInterface> propertiesOfCompleteObject = FlatProperties.getProperties(completeObject.getClass());
Map<String, PropertyInterface> properties = FlatProperties.getProperties(viewObject.getCl... | java |
public static <T> T viewed(View<T> viewObject) {
if (viewObject == null) return null;
@SuppressWarnings("unchecked")
Class<T> viewedClass = (Class<T>) getViewedClass(viewObject.getClass());
Object id = IdUtils.getId(viewObject);
if (id == null) {
return null;
}
return Backend.read(viewedClass,... | java |
public static ModelDiff createModelDiff(OpenEngSBModel before, OpenEngSBModel after) {
ModelDiff diff = new ModelDiff(before, after);
calculateDifferences(diff);
return diff;
} | java |
public static ModelDiff createModelDiff(OpenEngSBModel updated, String completeModelId,
EngineeringDatabaseService edbService, EDBConverter edbConverter) {
EDBObject queryResult = edbService.getObject(completeModelId);
OpenEngSBModel old = edbConverter.convertEDBObjectToModel(updated.getClas... | java |
private static void calculateDifferences(ModelDiff diff) {
Class<?> modelClass = diff.getBefore().getClass();
for (Field field : modelClass.getDeclaredFields()) {
if (field.getName().equals(ModelUtils.MODEL_TAIL_FIELD_NAME)) {
continue;
}
try {
... | java |
public void addDifference(Field field, Object before, Object after) {
ModelDiffEntry entry = new ModelDiffEntry();
entry.setBefore(before);
entry.setAfter(after);
entry.setField(field);
differences.put(field, entry);
} | java |
public boolean isForeignKeyChanged() {
return CollectionUtils.exists(differences.values(), new Predicate() {
@Override
public boolean evaluate(Object object) {
return ((ModelDiffEntry) object).isForeignKey();
}
});
} | java |
public boolean containsPoint(Coordinate point) {
Point p = new GeometryFactory().createPoint(point);
return this.getGeometry().contains(p);
} | java |
public static <ReturnType> ReturnType executeWithSystemPermissions(Callable<ReturnType> task)
throws ExecutionException {
ContextAwareCallable<ReturnType> contextAwareCallable = new ContextAwareCallable<ReturnType>(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubj... | java |
public static void executeWithSystemPermissions(Runnable task) {
ContextAwareRunnable contextAwaretask = new ContextAwareRunnable(task);
Subject newsubject = new Subject.Builder().buildSubject();
newsubject.login(new RootAuthenticationToken());
try {
newsubject.execute(contex... | java |
public static ExecutorService getSecurityContextAwareExecutor(ExecutorService original) {
SubjectAwareExecutorService subjectAwareExecutor = new SubjectAwareExecutorService(original);
return ThreadLocalUtil.contextAwareExecutor(subjectAwareExecutor);
} | java |
public static <BeanType> BeanType createBeanFromAttributeMap(Class<BeanType> beanType,
Map<String, ? extends Object> attributeValues) {
BeanType instance;
try {
instance = beanType.newInstance();
BeanUtils.populate(instance, attributeValues);
} catch (Exceptio... | java |
public synchronized void reloadRulebase() throws RuleBaseException {
long start = System.currentTimeMillis();
reloadDeclarations();
packageStrings.clear();
for (RuleBaseElementId id : manager.listAll(RuleBaseElementType.Function)) {
String packageName = id.getPackageName();
... | java |
@SuppressWarnings("unchecked")
public <T> T convertEDBObjectToModel(Class<T> model, EDBObject object) {
return (T) convertEDBObjectToUncheckedModel(model, object);
} | java |
public <T> List<T> convertEDBObjectsToModelObjects(Class<T> model, List<EDBObject> objects) {
List<T> models = new ArrayList<>();
for (EDBObject object : objects) {
T instance = convertEDBObjectToModel(model, object);
if (instance != null) {
models.add(instance);
... | java |
private boolean checkEDBObjectModelType(EDBObject object, Class<?> model) {
String modelClass = object.getString(EDBConstants.MODEL_TYPE);
if (modelClass == null) {
LOGGER.warn(String.format("The EDBObject with the oid %s has no model type information."
+ "The resulting m... | java |
private Object convertEDBObjectToUncheckedModel(Class<?> model, EDBObject object) {
if (!checkEDBObjectModelType(object, model)) {
return null;
}
filterEngineeringObjectInformation(object, model);
List<OpenEngSBModelEntry> entries = new ArrayList<>();
for (PropertyDes... | java |
private List<PropertyDescriptor> getPropertyDescriptorsForClass(Class<?> clasz) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(clasz);
return Arrays.asList(beanInfo.getPropertyDescriptors());
} catch (IntrospectionException e) {
LOGGER.error("instantiation excep... | java |
private Object getValueForProperty(PropertyDescriptor propertyDescriptor, EDBObject object) {
Method setterMethod = propertyDescriptor.getWriteMethod();
String propertyName = propertyDescriptor.getName();
Object value = object.getObject(propertyName);
Class<?> parameterType = setterMetho... | java |
@SuppressWarnings("unchecked")
private <T> List<T> getListValue(Class<T> type, String propertyName, EDBObject object) {
List<T> temp = new ArrayList<>();
for (int i = 0;; i++) {
String property = getEntryNameForList(propertyName, i);
Object obj = object.getObject(property);
... | java |
@SuppressWarnings("unchecked")
private <T> T[] getArrayValue(Class<T> type, String propertyName, EDBObject object) {
List<T> elements = getListValue(type, propertyName, object);
T[] ar = (T[]) Array.newInstance(type, elements.size());
return elements.toArray(ar);
} | java |
private Object getMapValue(Class<?> keyType, Class<?> valueType, String propertyName, EDBObject object) {
Map<Object, Object> temp = new HashMap<>();
for (int i = 0;; i++) {
String keyProperty = getEntryNameForMapKey(propertyName, i);
String valueProperty = getEntryNameForMapValu... | java |
private Object getEnumValue(Class<?> type, Object value) {
Object[] enumValues = type.getEnumConstants();
for (Object enumValue : enumValues) {
if (enumValue.toString().equals(value.toString())) {
value = enumValue;
break;
}
}
retur... | java |
public ConvertedCommit convertEKBCommit(EKBCommit commit) {
ConvertedCommit result = new ConvertedCommit();
ConnectorInformation information = commit.getConnectorInformation();
result.setInserts(convertModelsToEDBObjects(commit.getInserts(), information));
result.setUpdates(convertModels... | java |
private void fillEDBObjectWithEngineeringObjectInformation(EDBObject object, OpenEngSBModel model)
throws IllegalAccessException {
if (!new AdvancedModelWrapper(model).isEngineeringObject()) {
return;
}
for (Field field : model.getClass().getDeclaredFields()) {
Op... | java |
private void filterEngineeringObjectInformation(EDBObject object, Class<?> model) {
if (!AdvancedModelWrapper.isEngineeringObjectClass(model)) {
return;
}
Iterator<String> keys = object.keySet().iterator();
while (keys.hasNext()) {
if (keys.next().startsWith(REFER... | java |
public static String getEntryNameForMapKey(String property, Integer index) {
return getEntryNameForMap(property, true, index);
} | java |
public static String getEntryNameForMapValue(String property, Integer index) {
return getEntryNameForMap(property, false, index);
} | java |
private static String getEntryNameForMap(String property, Boolean key, Integer index) {
return String.format("%s.%d.%s", property, index, key ? "key" : "value");
} | java |
public static String getEntryNameForList(String property, Integer index) {
return String.format("%s.%d", property, index);
} | java |
public static String getEOReferenceStringFromAnnotation(OpenEngSBForeignKey key) {
return String.format("%s%s:%s", REFERENCE_PREFIX, key.modelType(), key.modelVersion().toString());
} | java |
private static Map<String, ModelDescription> assigneModelsToViews(Map<ModelDescription,
XLinkConnectorView[]> modelsToViews) {
HashMap<String, ModelDescription> viewsToModels = new HashMap<String, ModelDescription>();
for (ModelDescription modelInfo : modelsToViews.keySet()) {
L... | java |
private static String getExpirationDate(int futureDays) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, futureDays);
Format formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
return formatter.format(calendar.getTime());
} | java |
public static void setValueOfModel(Object model, OpenEngSBModelEntry entry, Object value) throws
NoSuchFieldException,
IllegalArgumentException,
IllegalAccessException {
Class clazz = model.getClass();
Field field = clazz.getDeclaredField(entry.getKey());
f... | java |
public static Object createInstanceOfModelClass(Class clazzObject,
List<OpenEngSBModelEntry> entries) {
return ModelUtils.createModel(clazzObject, entries);
} | java |
public static Calendar dateStringToCalendar(String dateString) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat(XLinkConstants.DATEFORMAT);
try {
calendar.setTime(formatter.parse(dateString));
} catch (Exception ex) {
... | java |
private static String urlEncodeParameter(String parameter) {
try {
return URLEncoder.encode(parameter, "UTF-8");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(XLinkUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return parameter;
} | java |
public static XLinkConnectorView[] getViewsOfRegistration(XLinkConnectorRegistration registration) {
List<XLinkConnectorView> viewsOfRegistration = new ArrayList<XLinkConnectorView>();
Map<ModelDescription, XLinkConnectorView[]> modelsToViews = registration.getModelsToViews();
for (XLinkConnecto... | java |
public static XLinkConnector[] getLocalToolFromRegistrations(List<XLinkConnectorRegistration> registrations) {
List<XLinkConnector> tools = new ArrayList<XLinkConnector>();
for (XLinkConnectorRegistration registration : registrations) {
XLinkConnector newLocalTools
= new XLi... | java |
private void mergeInTransaction(EntityManager em, Collection objects) {
EntityTransaction tx = null;
try {
tx = em.getTransaction();
tx.begin();
for (Object o : objects) {
em.merge(o);
}
tx.commit();
}
... | java |
public void execute() {
try {
new JdbcTemplate(dataSource).execute(readResourceContent(SCHEMA_FILE)); // TODO: sql independence
} catch (IOException e) {
throw new RuntimeException("Could not create schema for EDBI Index", e);
}
} | java |
public static void addId(Entry entry, boolean updateRdn) {
String uuid = newUUID().toString();
try {
entry.add(SchemaConstants.OBJECT_CLASS_ATTRIBUTE, UNIQUE_OBJECT_OC);
entry.add(ID_ATTRIBUTE, uuid);
} catch (LdapException e) {
throw new LdapRuntimeException(... | java |
public static void addIds(List<Entry> entries, boolean updateRdn) {
for (Entry entry : entries) {
addId(entry, updateRdn);
}
} | java |
protected synchronized void initialize() {
String invocationServiceName = this.invocationServiceName;
invocationService = (InvocationService)
CacheFactory.getService(invocationServiceName);
if (invocationService == null) {
throw new IllegalArgumentException("Invocatio... | java |
public void execute(Runnable command) {
if (!(command instanceof ClusteredFutureTask)) {
command = new ClusteredFutureTask<Object>(command, null);
}
command.run();
} | java |
protected synchronized Member getExecutionMember() {
Iterator<Member> it = memberIterator;
if (it == null || !it.hasNext()) {
memberIterator = it = serviceMembers.iterator();
}
return it.next();
} | java |
protected BrokerServiceAccessor getMethodAccessor(String serviceBrokerName, CatalogService description) {
return new AnnotationBrokerServiceAccessor(description, serviceBrokerName, getBeanClass(serviceBrokerName),
context.getBean(serviceBrokerName));
} | java |
protected Class<?> getBeanClass(String beanName) {
Class<?> clazz = context.getType(beanName);
while (Proxy.isProxyClass(clazz) || Enhancer.isEnhanced(clazz)) {
clazz = clazz.getSuperclass();
}
return clazz;
} | java |
public void skipSolver(ConstraintSolver ... solvers) {
if (solversToSkip == null) solversToSkip = new HashSet<ConstraintSolver>();
for (ConstraintSolver solver : solvers) solversToSkip.add(solver);
} | java |
private void initAttributesAndElements(String... propertyNames)
{
for (String propertyName : propertyNames)
{
Property property = new Property(propertyName);
if (property.isAttribute())
{
m_attributes.add(property);
}
... | java |
public void setUsed(boolean newVal){
if(isUsed() && newVal == false) {
Arrays.fill(out, null);
}
used = newVal;
} | java |
private Character getPadCharacter(String characterString) {
if (characterString.length() > 0) {
getLogger().debug("The given character string is longer than one element. The first character is used.");
}
return characterString.charAt(0);
} | java |
private String getDirectionString(String direction) {
if (direction == null || !(direction.equals("Start") || direction.equals("End"))) {
getLogger().debug("Unrecognized direction string. The standard value 'Start' will be used.");
return "Start";
}
return direction;
... | java |
private String performPadOperation(String source, Integer length, Character padChar, String direction) {
if (direction.equals("Start")) {
return Strings.padStart(source, length, padChar);
} else {
return Strings.padEnd(source, length, padChar);
}
} | java |
public List<Project> findAllProjects() {
List<Project> list = new ArrayList<>();
List<String> projectNames;
try {
projectNames = readLines(projectsFile);
} catch (IOException e) {
throw new FileBasedRuntimeException(e);
}
for (String projectName : ... | java |
public static Map<String, Class<?>> getPropertyTypeMap(Class<?> clazz, String... exclude) {
PropertyDescriptor[] descriptors;
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
... | java |
public static Map<String, Object> read(Object object) {
PropertyDescriptor[] descriptors;
Class<?> clazz = object.getClass();
try {
descriptors = getPropertyDescriptors(clazz);
} catch (IntrospectionException e) {
LOG.error("Failed to introspect " + clazz, e);
... | java |
public static AdvancedModelWrapper wrap(Object model) {
if (!(isModel(model.getClass()))) {
throw new IllegalArgumentException("The given object is no model");
}
return new AdvancedModelWrapper((OpenEngSBModel) model);
} | java |
public List<EDBObject> getModelsReferringToThisModel(EngineeringDatabaseService edbService) {
return edbService.query(QueryRequest.query(
EDBConverter.REFERENCE_PREFIX + "%", getCompleteModelOID()));
} | java |
public static Boolean isEngineeringObjectClass(Class<?> clazz) {
for (Field field : clazz.getDeclaredFields()) {
if (field.isAnnotationPresent(OpenEngSBForeignKey.class)) {
return true;
}
}
return false;
} | java |
public static <T> T convertObject(String json, Class<T> clazz) throws IOException {
try {
if (clazz.isAnnotationPresent(Model.class)) {
return MODEL_MAPPER.readValue(json, clazz);
}
return MAPPER.readValue(json, clazz);
} catch (IOException e) {
... | java |
public IndexCommit convert(EKBCommit ekbCommit) {
IndexCommit commit = new IndexCommit();
commit.setCommitId(ekbCommit.getRevisionNumber());
commit.setParentCommitId(ekbCommit.getParentRevisionNumber());
commit.setConnectorId(ekbCommit.getConnectorId());
commit.setDomainId(ekbCo... | java |
protected Map<Class<?>, List<OpenEngSBModel>> mapByClass(Collection<OpenEngSBModel> models) {
return group(models, new Function<OpenEngSBModel, Class<?>>() {
@Override
public Class<?> apply(OpenEngSBModel input) {
return input.getClass();
}
});
} | java |
public Catalog createCatalog() {
final List<CatalogService> services = new ArrayList<>();
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
services.add(serviceAccessor.getServiceDescription());
}
return new Catalog(services);
} | java |
public BrokerServiceAccessor getServiceAccessor(String serviceId) {
for (BrokerServiceAccessor serviceAccessor : serviceAccessors) {
if (serviceId.equals(serviceAccessor.getServiceDescription().getId())) {
return serviceAccessor;
}
}
throw new NotFoundExc... | java |
public static void setIdFieldValue(ODocument document, String value) {
setFieldValue(document, OGraphDatabase.LABEL, value);
} | java |
public static void setActiveFieldValue(ODocument document, Boolean active) {
setFieldValue(document, ACTIVE_FIELD, active.toString());
} | java |
public static String getFieldValue(ODocument document, String fieldname) {
return (String) document.field(fieldname);
} | java |
public static void setFieldValue(ODocument document, String fieldname, String value) {
document.field(fieldname, value);
} | java |
public static void fillEdgeWithPropertyConnections(ODocument edge, TransformationDescription description) {
Map<String, String> connections = convertPropertyConnectionsToSimpleForm(description.getPropertyConnections());
for (Map.Entry<String, String> entry : connections.entrySet()) {
edge.fi... | java |
public int[][] getVariations() {
int permutations = (int) Math.pow(n, r);
int[][] table = new int[permutations][r];
for (int x = 0; x < r; x++) {
int t2 = (int) Math.pow(n, x);
for (int p1 = 0; p1 < permutations;) {
for (int al = 0; al < n; al++) {
for (int p2 = 0; p2 < t2; p2++) {
table[p1]... | java |
private List<JPAObject> checkInserts(List<JPAObject> inserts) {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject insert : inserts) {
String oid = insert.getOID();
if (checkIfActiveOidExisting(oid)) {
failedObjects.add(insert);
... | java |
private List<String> checkDeletions(List<String> deletes) {
List<String> failedObjects = new ArrayList<String>();
for (String delete : deletes) {
if (!checkIfActiveOidExisting(delete)) {
failedObjects.add(delete);
}
}
return failedObjects;
} | java |
private List<JPAObject> checkUpdates(List<JPAObject> updates) throws EDBException {
List<JPAObject> failedObjects = new ArrayList<JPAObject>();
for (JPAObject update : updates) {
try {
Integer modelVersion = investigateVersionAndCheckForConflict(update);
model... | java |
private Integer investigateVersionAndCheckForConflict(JPAObject newObject) throws EDBException {
JPAEntry entry = newObject.getEntry(EDBConstants.MODEL_VERSION);
String oid = newObject.getOID();
Integer modelVersion = 0;
if (entry != null) {
modelVersion = Integer.parseInt(e... | java |
private void checkForConflict(JPAObject newObject) throws EDBException {
String oid = newObject.getOID();
JPAObject object = dao.getJPAObject(oid);
for (JPAEntry entry : newObject.getEntries()) {
if (entry.getKey().equals(EDBConstants.MODEL_VERSION)) {
continue;
... | java |
@Override
public void execute() throws MojoExecutionException {
checkParameters();
windowsModus = isWindows();
if (windowsModus) {
setWindowsVariables();
} else {
setLinuxVariables();
}
createDllFromWsdl();
} | java |
private void createDllFromWsdl() throws MojoExecutionException {
getLog().info("Execute WSDl to cs command");
wsdlCommand();
getLog().info("Execute cs to dll command");
cscCommand();
if (generateNugetPackage) {
if (isLinux()) {
throw new MojoExecutionE... | java |
private void wsdlCommand() throws MojoExecutionException {
String cmd = findWsdlCommand();
int i = 0;
for (String location : wsdlLocations) {
String outputFilename = new File(outputDirectory, namespace + (i++)
+ ".cs").getAbsolutePath();
String[] comma... | java |
private void cscCommand() throws MojoExecutionException {
generateAssemblyInfo();
String cscPath = findCscCommand();
List<String> commandList = new LinkedList<String>(cspath);
commandList.add(0, cscPath);
commandList.add(1, "/target:library");
commandList.add(2, "/out:" +... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.