code
stringlengths
73
34.1k
label
stringclasses
1 value
public static RecordingTransaction wrap(Transaction tx, Predicate<LogEntry> filter) { return new RecordingTransaction(tx, filter); }
java
protected InputContainerElements scan(final UIComponent component, InputContainerElements elements, final FacesContext context) { if (elements == null) { elements = new InputContainerElements(); } // NOTE we need to walk the tree ignoring rendered attribute because it's ...
java
public void assignIds(final InputContainerElements elements, final FacesContext context) { boolean refreshIds = false; if (getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) { setId(elements.getPropertyName(context)); refreshIds = true; } UIComponent label = element...
java
private Validator getDefaultValidator(final FacesContext context) throws FacesException { if (!beanValidationPresent) { return null; } ValidatorFactory validatorFactory; Object cachedObject = context.getExternalContext().getApplicationMap().get(BeanValidator.VALIDATOR_FACTOR...
java
public @Nonnull SetType getBlockedThreads() { Set<ThreadType> blocked = new LinkedHashSet<ThreadType>(); for (ThreadType thread: runtime.getThreads()) { if (thread == this) continue; if (getAcquiredLocks().contains(thread.getWaitingToLock())) { blocked.add(thread)...
java
public @Nonnull SetType getBlockingThreads() { final ThreadType blocking = getBlockingThread(); if (blocking == null) return runtime.getEmptyThreadSet(); return runtime.getThreadSet(Collections.singleton(blocking)); }
java
public @CheckForNull ThreadType getBlockingThread() { if (state.waitingToLock == null && state.waitingOnLock == null) { return null; } for (ThreadType thread: runtime.getThreads()) { if (thread == this) continue; Set<ThreadLock> acquired = thread.getAcquiredL...
java
private void init(String xmlPath) throws MalformedURLException, IOException{ XML xml = new XML(true, xmlPath); if(!xml.isInheritedMapped(configuredClass)) Error.classNotMapped(configuredClass); for (Class<?> classe :getClasses(xml)){ relationalManyToOneMapper.put(classe.getName(), new JMapper(c...
java
private Set<Class<?>> getClasses(XML xml){ HashSet<Class<?>> result = new HashSet<Class<?>>(); // in case of override only the last global configuration must be analyzed Global global = null; for (Class<?> clazz : getAllsuperClasses(configuredClass)) { // only if global configuration is null wil...
java
private void init(){ if(!Annotation.isInheritedMapped(configuredClass)) Error.classNotMapped(configuredClass); for (Class<?> classe :getClasses()){ relationalManyToOneMapper.put(classe.getName(), new JMapper(configuredClass, classe,ChooseConfig.DESTINATION)); relationalOneToManyMapper.put(class...
java
private Set<Class<?>> getClasses() { HashSet<Class<?>> result = new HashSet<Class<?>>(); // in case of override only the last global configuration must be analyzed JGlobalMap jGlobalMap = null; for (Class<?> clazz : getAllsuperClasses(configuredClass)) { // only if global configuration is n...
java
private <I> I destinationClassControl(Exception exception, Class<I> clazz){ try{ if(clazz == null)throw new IllegalArgumentException("it's mandatory define the destination class"); }catch (Exception e) {JmapperLog.error(e);return null;} return logAndReturnNull(exception); }
java
private <D,S> JMapper<D,S> getJMapper(HashMap<String,JMapper> map,Object source){ Class<?> sourceClass = source instanceof Class?((Class<?>)source):source.getClass(); JMapper<D,S> jMapper = map.get(sourceClass.getName()); if(jMapper == null) Error.classNotMapped(source, configuredClass); return jMapper; }
java
public Global excludedAttributes(String... attributes){ for (String attribute : attributes) global.excluded.add(new XmlExcludedAttribute(attribute)); return this; }
java
public Global targetClasses(Class<?>... classes){ for (Class<?> targetClass : classes) global.classes.add(new TargetClass(targetClass).toXStream()); return this; }
java
public boolean isUndefined(final Field destination,final Field source) { info = null; for (IOperationAnalyzer analyzer : analyzers) if(analyzer.verifyConditions(destination,source)) info = analyzer.getInfoOperation(destination, source); // if the operation has not been identified if(is...
java
private String getValue(final String value, final String mappedFieldName) { if (isNull(value)) return null; return value.equals(DEFAULT_FIELD_VALUE)?mappedFieldName:value; }
java
private String getValue(final List<String> attributes,final List<Class<?>> classes,String value,final String mappedFieldName,final Class<?> configuredClass,final Class<?> targetClass){ String regex = getValue(value,mappedFieldName); String mappedClassName = configuredClass.getSimpleName(); String targetCla...
java
public void loadAccessors(Class<?> targetClass, MappedField configuredField, MappedField targetField) { // First checks xml configuration xml.fillMappedField(configuredClass, configuredField) .fillMappedField(targetClass, targetField) // fill target field with custom methods defined in the configured...
java
public List<ConversionMethod> getConversionMethods (Class<?> clazz){ List<ConversionMethod> conversions = new ArrayList<ConversionMethod>(); Map<String, List<ConversionMethod>> conversionsMap = this.conversionsLoad(); for (Class<?> classToCheck : getAllsuperClasses(clazz)){ List<ConversionMethod> methods =...
java
public List<String> getClasses(){ List<String> classes = new ArrayList<String>(); for (XmlClass xmlClass : xmlJmapper.classes) classes.add(xmlClass.name); return classes; }
java
public XML write(){ try { FilesManager.write(xmlJmapper, xmlPath); } catch (IOException e) {JmapperLog.error(e);} return this; }
java
public XML deleteClass(Class<?> aClass){ boolean isRemoved = xmlJmapper.classes.remove(new XmlClass(aClass.getName())); if(!isRemoved)Error.xmlClassInexistent(this.xmlPath,aClass); return this; }
java
public XML addGlobal(Class<?> aClass,Global global){ checksGlobalAbsence(aClass); findXmlClass(aClass).global = Converter.toXmlGlobal(global); return this; }
java
public XML deleteGlobal(Class<?> aClass){ checksGlobalExistence(aClass); XmlClass xmlClass = findXmlClass(aClass); if(isEmpty(xmlClass.attributes)) deleteClass(aClass); else xmlClass.global = null; return this; }
java
public XML addAttributes(Class<?> aClass,Attribute[] attributes){ checksAttributesExistence(aClass,attributes); for (Attribute attribute : attributes) { if(attributeExists(aClass,attribute)) Error.xmlAttributeExistent(this.xmlPath,attribute, aClass); findXmlClass(aClass).attributes.add(Converter.toXml...
java
public XML deleteAttributes(Class<?> aClass,String[] attributes){ checksAttributesExistence(aClass,attributes); if(isEmpty(findXmlClass(aClass).attributes) || findXmlClass(aClass).attributes.size()<=1) Error.xmlWrongMethod(aClass); for (String attributeName : attributes) { XmlAttribute attribut...
java
private XML addClass(Class<?> aClass){ xmlJmapper.classes.add(Converter.toXmlClass(aClass)); return this; }
java
private XML checksClassAbsence(Class<?> aClass){ if(classExists(aClass))Error.xmlClassExistent(this.xmlPath,aClass); return this; }
java
private boolean classExists(Class<?> aClass) { if(xmlJmapper.classes == null)return false; return findXmlClass(aClass) !=null?true:false; }
java
private boolean attributeExists(Class<?> aClass,Attribute attribute){ if(!classExists(aClass))return false; for (XmlAttribute xmlAttribute : findXmlClass(aClass).attributes) if(xmlAttribute.name.equals(attribute.getName()))return true; return false; }
java
private XmlClass findXmlClass(Class<?> aClass){ for (XmlClass xmlClass : xmlJmapper.classes) if(xmlClass.name.equals(aClass.getName())) return xmlClass; return null; }
java
public boolean isMapped(Class<?> classToCheck){ return !isNull(loadGlobals().get(classToCheck.getName())) || !isEmpty(loadAttributes().get(classToCheck.getName())); }
java
public XML fillMappedField(Class<?> configuredClass, MappedField configuredField) { Attribute attribute = getGlobalAttribute(configuredField, configuredClass); if(isNull(attribute)) attribute = getAttribute(configuredField, configuredClass); if(!isNull(attribute)){ if(isEmpty(configuredFiel...
java
public XML fillOppositeField(Class<?> configuredClass, MappedField configuredField, MappedField targetField) { Attribute attribute = null; Global global = loadGlobals().get(configuredClass.getName()); if(!isNull(global)){ String value = global.getValue(); if(!isEmpty(value) && value.equals(targetF...
java
public static boolean safeNavigationOperatorDefined(String nestedFieldName){ if(nestedFieldName.contains(SAFE_NAVIGATION_OPERATOR)) if(!nestedFieldName.startsWith(SAFE_NAVIGATION_OPERATOR)) //TODO standardizzare exception throw new MappingException("Safe navigation operator must be the first symbol aft...
java
private static MappedField checkGetAccessor(XML xml, Class<?> aClass, Field nestedField){ MappedField field = new MappedField(nestedField); xml.fillMappedField(aClass, field); Annotation.fillMappedField(aClass,field); verifyGetterMethods(aClass,field); return field; }
java
private static MappedField checkAccessors(XML xml, Class<?> aClass, Field nestedField){ MappedField field = checkGetAccessor(xml, aClass, nestedField); verifySetterMethods(aClass,field); return field; }
java
public static NestedMappingInfo loadNestedMappingInformation(XML xml, Class<?> targetClass,String nestedMappingPath, Class<?> sourceClass, Class<?> destinationClass, Field configuredField){ boolean isSourceClass = targetClass == sourceClass; NestedMappingInfo info = new NestedMappingInfo(isSourceClass); ...
java
public static AGeneralOperation getOperation(OperationType operationType){ switch(operationType){ case BASIC_INSTRUCTION: return new BasicOperation(); case BASIC_CONVERSION: return new BasicConversion(); case OBJECT: return new ObjectOperation(); case ARRAY: r...
java
public static InputStream loadResource(String resource) throws MalformedURLException, IOException{ String content = resource.trim(); // if resource is a content and not a path if(!isPath(content)) return new ByteArrayInputStream(content.getBytes("UTF-8")); URL url = Thread.currentThread()....
java
public boolean fieldsToCheck(Field destination, Field source){ destinationName = destination.getName(); sourceName = source.getName(); if(!xml.conversionsLoad().isEmpty()){ configurationType = XML; if(config == DESTINATION){ if(existsXmlConversion(destinationClass)) { membership = Membership.DESTI...
java
private boolean exists(List<ConversionMethod> conversions){ if(conversions.isEmpty()) return false; return (method = verifyConversionExistence(conversions))!= null; }
java
private ConversionMethod verifyConversionExistence(List<ConversionMethod> conversions){ for (ConversionMethod method : conversions) if(isPresentIn(method.getFrom(),sourceName) && isPresentIn(method.getTo() ,destinationName)) return method; return null; }
java
private boolean isPresentIn(String[] values, String field){ for (String value : values) if(value.equalsIgnoreCase(JMapConversion.ALL) || value.equals(field)) return true; return false; }
java
public static void nestedBeanNull(String currentField, String destinationClass, String destinationField, String sourceClass, String sourceField, boolean safeNavigationOperator){ throw new NestedBeanNullException(MSG.INSTANCE.message(nestedBeanNullException,currentField,destinationClass,destinationField,sourceClass,s...
java
public static void bodyContainsIllegalCode(Method method, Exception additionalInformation){ Class<?> clazz = method.getClazz(); if(isNull(clazz)) clazz = JMapper.class; String originalName = method.getOriginalName(); if(isNull(originalName)) originalName = method.getName(); String message = clazz...
java
public static void incorrectMethodDefinition(String methodName, String className){ throw new DynamicConversionMethodException(MSG.INSTANCE.message(dynamicConversionMethodException,methodName,className)); }
java
public static void incorrectBodyDefinition(String methodName,String className){ throw new DynamicConversionBodyException(MSG.INSTANCE.message(dynamicConversionBodyException,methodName,className)); }
java
public static void attributeInexistent(String attributeName, Class<?> aClass){ throw new IllegalArgumentException(MSG.INSTANCE.message(malformedBeanException2,attributeName,aClass.getSimpleName())); }
java
public static void xmlWrongMethod(Class<?> aClass){ throw new WrongMethodException (MSG.INSTANCE.message(wrongMethodException1,aClass.getSimpleName())); }
java
public static void xmlClassInexistent(String path, Class<?> aClass){ throw new XmlMappingClassDoesNotExistException (MSG.INSTANCE.message(xmlMappingClassDoesNotExistException1,path,aClass.getSimpleName())); }
java
public static void xmlClassExistent(String path, Class<?> aClass){ throw new XmlMappingClassExistException (MSG.INSTANCE.message(xmlMappingClassExistException1,aClass.getSimpleName(),path)); }
java
public static void xmlConversionNameUndefined(String xmlPath, String className) { throw new XmlConversionNameException(MSG.INSTANCE.message(xmlConversionNameException,xmlPath,className)); }
java
public static void xmlConversionTypeIncorrect(String conversionName,String xmlPath,String className,String type){ throw new XmlConversionTypeException(MSG.INSTANCE.message(xmlConversionTypeException,conversionName,xmlPath,className,type)); }
java
public static void improperUseOfTheParameter(String conversionName,String xmlPath,String className){ throw new XmlConversionParameterException(MSG.INSTANCE.message(xmlConversionParameterException,conversionName,xmlPath,className)); }
java
public static void undefinedMapping(Field destinationField, Class<?> destinationClass, Field sourceField, Class<?> sourceClass){ throw new UndefinedMappingException(MSG.INSTANCE.message(undefinedMappingException,destinationField.getName(),destinationClass.getSimpleName(),sourceField.getName(),sourceClass.getSimpleNa...
java
public static void badConversion(Field destinationField, Class<?> destinationClass, Field sourceField, Class<?> sourceClass,String plus){ throw new UndefinedMappingException(MSG.INSTANCE.message(undefinedMappingException,destinationField.getName(),destinationClass.getSimpleName(),sourceField.getName(),sourceClass.ge...
java
public static void mapping(String mappedFieldName,Class<?> mappedClass, Class<?> targetClass){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException2,mappedFieldName,mappedClass.getSimpleName(),targetClass.getSimpleName())); }
java
public static void mapping(String mappedFieldName, String mappedClassName){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException2length,mappedFieldName,mappedClassName)); }
java
public static void mapping(String mappedFieldName, String mappedClassName, String targetClassName){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException3,mappedFieldName,mappedClassName,targetClassName)); }
java
public static void attributeAbsent(Class<?> aClass,Attribute aField){ throw new XmlMappingAttributeDoesNotExistException(MSG.INSTANCE.message(xmlMappingAttributeDoesNotExistException2,aField.getName(),aClass.getSimpleName(),"API")); }
java
public static void configNotPresent(Class<?> destination,Class<?> source,XML xml){ throw new MappingNotFoundException(MSG.INSTANCE.message(Constants.mappingNotFoundException2path,destination.getSimpleName(), source.getSimpleName(),xml.getXmlPath())); }
java
public static void configNotPresent(Class<?> clazz,XML xml){ throw new MappingNotFoundException(MSG.INSTANCE.message(Constants.mappingNotFoundException1path, clazz.getSimpleName(),xml.getXmlPath())); }
java
public static void classesNotConfigured(Class<?> destination,Class<?> source){ throw new MappingNotFoundException(MSG.INSTANCE.message(Constants.mappingNotFoundException2,destination.getSimpleName(), source.getSimpleName())); }
java
public static void classNotConfigured(Class<?> clazz){ throw new MappingNotFoundException(MSG.INSTANCE.message(Constants.mappingNotFoundException1, clazz.getSimpleName())); }
java
public static void globalClassesAbsent(Class<?> aClass){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorRelationalException3, aClass.getSimpleName())); }
java
public static void classesAbsent(String fieldName,Class<?> aClass){ throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorRelationalException2,fieldName, aClass.getSimpleName())); }
java
public static void classNotMapped(Class<?> aClass){ throw new ClassNotMappedException(MSG.INSTANCE.message(classNotMappedException1,aClass.getSimpleName())); }
java
public static void classNotMapped(Object sourceClass, Class<?> configuredClass){ String sourceName = sourceClass instanceof Class?((Class<?>)sourceClass).getSimpleName():sourceClass.getClass().getSimpleName(); throw new ClassNotMappedException(MSG.INSTANCE.message(classNotMappedException2,sourceName, configuredCl...
java
public static void illegalCode(Class<?> destination, Class<?> source, String path, Throwable e){ String additionalInformation = e.getMessage().split(",")[1]; throw new IllegalCodeException(MSG.INSTANCE.message(illegalCodePath,destination.getSimpleName(),source.getSimpleName(),path,additionalInformation)); }
java
public static void absentRelationship(Class<?> configuredClass, Class<?> targetClass){ throw new AbsentRelationshipException(MSG.INSTANCE.message(noRelationshipException,configuredClass.getSimpleName(),targetClass.getSimpleName())); }
java
public static void emptyConstructorAbsent(Class<?> aClass){ throw new MalformedBeanException(MSG.INSTANCE.message(malformedBeanException1,aClass.getSimpleName())); }
java
protected ChooseConfig searchConfig(ChooseConfig cc, XML xml){ ChooseConfig config = searchXmlConfig(cc, xml); if(isNull(config))config = searchAnnotatedConfig(cc); return config; }
java
private ChooseConfig searchXmlConfig(ChooseConfig cc, XML xml){ if(isNull(xml.getXmlPath())) return null; if((isNull(cc)||cc == ChooseConfig.DESTINATION) && xml.isInheritedMapped(destination)) return ChooseConfig.DESTINATION; if((isNull(cc)||cc == ChooseConfig.SOURCE) && xml.isInheritedMa...
java
private ChooseConfig searchAnnotatedConfig(ChooseConfig cc) { if((isNull(cc)||cc == ChooseConfig.DESTINATION) && Annotation.isInheritedMapped(destination)) return ChooseConfig.DESTINATION; if((isNull(cc)||cc == ChooseConfig.SOURCE) && Annotation.isInheritedMapped(source)) return ChooseConfig.S...
java
public static JMapAccessor getFieldAccessors(Class<?> clazz, Field field){ return getFieldAccessors(clazz,field,false, field.getName(),Constants.DEFAULT_FIELD_VALUE); }
java
private static JMapAccessor getAccessor(Class<?> clazz, java.lang.annotation.Annotation[] annotations, String fieldName, boolean isOpposite){ for (java.lang.annotation.Annotation annotation : annotations) { if(annotation.annotationType() == JMapAccessors.class){ JMapAccessors jmapAccessors = (JMapAccessors)...
java
public static List<ConversionMethod> getConversionMethods(Class<?> clazz){ List<ConversionMethod> conversions = new ArrayList<ConversionMethod>(); for(Method method:getAnnotatedMethods(clazz)) try{ conversions.add(Converter.toConversionMethod(method)); }catch (ConversionParameterException e) { ...
java
private static List<Method> getAnnotatedMethods(Class<?> clazz){ List<Method> methods = new ArrayList<Method>(); for(Method method:getAllMethods(clazz)) if(!isNull(method.getAnnotation(JMapConversion.class))) methods.add(method); return methods; }
java
public static boolean isInheritedMapped(Class<?> classToCheck){ for (Class<?> clazz : getAllsuperClasses(classToCheck)) if(!isNull(clazz.getAnnotation(JGlobalMap.class))) return true; for (Field field : getListOfFields(classToCheck)) if(!isNull(field.getAnnotation(JMap.class))) return ...
java
public static ConversionType getConversionType(final Field destination, final Field source){ return getConversionType(destination.getType(),source.getType()); }
java
public static ConversionType getConversionType(final Class<?> destination, final Class<?> source){ if(destination == String.class) return toStringConversion(source); if(destination == Byte.class) return toByteConversion(source); if(destination == byte.class) return tobyteConversion(source); if(dest...
java
private Class<?> defineStructure(Field destination, Field source){ Class<?> destinationClass = destination.getType(); Class<?> sourceClass = source.getType(); Class<?> result = null; // if destination is an interface if(destinationClass.isInterface()) // if source is an interface if(s...
java
public static <D,S> IJMapper<D, S> getMapper(final Class<D> destination, final Class<S> source){ return getMapper(destination,source, undefinedConfig()); }
java
private static String relationalMapperName(Class<?> configuredClass, String resource){ String className = configuredClass.getName().replaceAll("\\.",""); if(isEmpty(resource)) return className; if(!isPath(resource)) return write(className, String.valueOf(resource.hashCode())); String[]dep = r...
java
public static Attribute attribute(String name, String customGet, String customSet){ return new Attribute(name, customGet, customSet); }
java
public static TargetAttribute targetAttribute(String name, String customGet, String customSet){ return new TargetAttribute(name, customGet, customSet); }
java
public static LocalAttribute localAttribute(String name, String customGet, String customSet){ return new LocalAttribute(name, customGet, customSet); }
java
public static void error(Throwable e) throws JMapperException{ logger.error("{}: {}",e.getClass().getSimpleName(),e.getMessage()); throw new JMapperException(e); }
java
protected final StringBuilder write(StringBuilder sb,final Object... objects){ for (Object string : objects)sb.append(string); return sb; }
java
public Method loadMethod(){ methodToGenerate = new Method(); // the method will be created in the mapper membership = Membership.MAPPER; // class to which it belongs methodToGenerate.setClazz(configClass); Class<?> destinationClass = destinationField.getType(); Class<?> sourceClass = source...
java
private String defaultPrimitiveValue(Class<?> clazz){ return clazz == byte.class || clazz == short.class || clazz == int.class? "0": clazz == long.class? "0L": clazz == float.class? "0.0f": clazz == double.class? "0.0d": clazz == char.class ? "'\u0000'": clazz ...
java
private String error(){ Map<String, List<ConversionMethod>> conversions = xml.conversionsLoad(); String methodName = "illegalCode"; String paramater = ""; String resource = xml.getXmlPath(); if(!isNull(resource)){ boolean isPath = isPath(resource); methodName = !isPath ? "illegalCode...
java
public ConversionHandler load(ConversionAnalyzer analyzer){ this.methodDefined = analyzer.getMethod(); this.membership = analyzer.getMembership(); this.configClass = membership == Membership.DESTINATION?destinationClass:sourceClass; this.configurationType = analyzer.getConfigurationType(); return this; ...
java
public ConversionHandler from(MappedField sourceMappedField){ this.sourceField = sourceMappedField.getValue(); placeholders.put(sourceTypePattern, sourceField.getType().getName()); placeholders.put(sourceNamePattern, sourceField.getName()); placeholders.put(sourceGetPattern, sourceMappedField.getMethod()); ...
java
public ConversionHandler to(MappedField destinationMappedField){ this.destinationField = destinationMappedField.getValue(); placeholders.put(destinationTypePattern, destinationField.getType().getName()); placeholders.put(destinationNamePattern, destinationField.getName()); placeholders.put(destinationGetPa...
java
private static synchronized <D,S> IMapper<D,S> createMapper(MapperBuilder mapper) throws Throwable{ Class<Mapper<D,S>> mapperClass = mapper.exist()?mapper.<D,S>get() :mapper.<D,S>generate(); return mapperClass.newInstance(); }
java
public JMapper<D, S> destinationFactory(DestinationFactory<D> factory){ this.mapper.setDestinationFactory(factory); return this; }
java
public static boolean isAssignableFrom(Class<?> destination,Class<?> source){ return destination.isAssignableFrom(source) || isBoxing(destination,source) || isUnBoxing(destination,source); }
java