/* --- Private methods ---
775934
private String[] createResolversIncludesPattern(Collection<AbstractDependencyResolver> dependencyResolvers) {
        Collection<String> resultIncludes = new ArrayList<>();
        // TODO - check if can be done with lambda
        for (AbstractDependencyResolver dependencyResolver : dependencyResolvers) {
            for (String manifestFile : dependencyResolver.getManifestFiles()){
                if (!manifestFile.isEmpty()) {
                    resultIncludes.add(Constants.PATTERN + manifestFile);
                }
            }
        }
        String[] resultArray = new String[resultIncludes.size()];
        resultIncludes.toArray(resultArray);
        return resultArray;
    }
1374179
public function process()
    {
        parent::process();

        if ($this->value === null) {
            return;
        }

        $float_value = $this->getNumericValue($this->value);

        if ($float_value === null) {
            $this->addMessage($this->getValidationMessage('float'));
        } else {
            $this->value = $float_value;
        }
    }
727730
@Override
    public void onXml(ClientProperties cp)
    {
        hsmd.onInitialize();
        if (cp != null)
        {
            hsmd.setClientProperties(cp);
        }
    }
926866
@Override
    public <V extends FileAttributeView> V getFileAttributeView(final Path path, final Class<V> type,
        final LinkOption... options) {
        if (path == null) {
            throw new IllegalArgumentException("path must be specified");
        }
        if (type == null) {
            throw new IllegalArgumentException("type must be specified");
        }
        if (!type.isAssignableFrom(ShrinkWrapFileAttributeView.class)) {
            // Nope, we don't support this view
            return null;
        }
        if (!(path instanceof ShrinkWrapPath)) {
            throw new IllegalArgumentException("Only " + ShrinkWrapPath.class.getSimpleName() + " is supported");
        }
        return type.cast(new ShrinkWrapFileAttributeView(new ShrinkWrapFileAttributes((ShrinkWrapPath) path,
                getArchive(path))));
    }
82160
private void putPropertyStrings(Service s) {
        String type = s.getType();
        String algorithm = s.getAlgorithm();
        // use super() to avoid permission check and other processing
        super.put(type + "." + algorithm, s.getClassName());
        for (String alias : s.getAliases()) {
            super.put(ALIAS_PREFIX + type + "." + alias, algorithm);
        }
        for (Map.Entry<UString,String> entry : s.attributes.entrySet()) {
            String key = type + "." + algorithm + " " + entry.getKey();
            super.put(key, entry.getValue());
        }
        if (registered) {
            Security.increaseVersion();
        }
    }
1271432
@Override
    public String[] decode(long generation, String tableName, List<VoltType> types, List<String> names, String[] to, Object[] fields) throws RuntimeException {
        Preconditions.checkArgument(
                fields != null && fields.length > m_firstFieldOffset,
                "null or inapropriately sized export row array"
        );
        /*
         * Builds a list of string formatters that reflects the row
         * column types.
         */
        StringFieldDecoder [] fieldDecoders;
        if (!m_fieldDecoders.containsKey(generation)) {
            int fieldCount = 0;
            Map<String, DecodeType> typeMap = getTypeMap(generation, types, names);
            ImmutableList.Builder<StringFieldDecoder> lb = ImmutableList.builder();
            for (org.voltdb.exportclient.decode.DecodeType dt: typeMap.values()) {
                lb.add(dt.accept(decodingVisitor, fieldCount++, null));
            }

            fieldDecoders = lb.build().toArray(new StringFieldDecoder[0]);
            m_fieldDecoders.put(generation, fieldDecoders);
        } else {
            fieldDecoders = m_fieldDecoders.get(generation);
        }
        if (to == null || to.length < fieldDecoders.length) {
            to = new String[fieldDecoders.length];
        }
        for (
                int i = m_firstFieldOffset, j = 0;
                i < fields.length && j < fieldDecoders.length;
                ++i, ++j
        ) {
            fieldDecoders[j].decode(to, fields[i]);
        }

        return to;
    }
1178170
@Override
    public void readExternal(ObjectInput in)
        throws IOException, ClassNotFoundException {

        int header = in.readByte();

        switch (header) {
            case FIXED_DAY_PATTERN_TYPE:
                this.obj = readFixedDayPattern(in);
                break;
            case DAY_OF_WEEK_IN_MONTH_PATTERN_TYPE:
                this.obj = readDayOfWeekInMonthPattern(in);
                break;
            case LAST_WEEKDAY_PATTERN_TYPE:
                this.obj = readLastDayOfWeekPattern(in);
                break;
            case RULE_BASED_TRANSITION_MODEL_TYPE:
                this.obj = readRuleBasedTransitionModel(in);
                break;
            case ARRAY_TRANSITION_MODEL_TYPE:
                this.obj = readArrayTransitionModel(in);
                break;
            case COMPOSITE_TRANSITION_MODEL_TYPE:
                this.obj = readCompositeTransitionModel(in);
                break;
            default:
                throw new StreamCorruptedException("Unknown serialized type.");
        }

    }
613785
function Mapping() {
    this.generatedLine = 0;
    this.generatedColumn = 0;
    this.source = null;
    this.originalLine = null;
    this.originalColumn = null;
    this.name = null;
  }
372496
private void processHeaderString(String dataHeader) {
		isFile = dataHeader.indexOf("filename") > 0;
		formFieldName = getDataFieldValue(dataHeader, "name");
		if (isFile) {
			formFileName = getDataFieldValue(dataHeader, "filename");
			if (formFileName == null) {
				return;
			}
			if (formFileName.length() == 0) {
				path = StrUtil.EMPTY;
				fileName = StrUtil.EMPTY;
			}
			int ls = FileUtil.lastIndexOfSeparator(formFileName);
			if (ls == -1) {
				path = StrUtil.EMPTY;
				fileName = formFileName;
			} else {
				path = formFileName.substring(0, ls);
				fileName = formFileName.substring(ls);
			}
			if (fileName.length() > 0) {
				this.contentType = getContentType(dataHeader);
				mimeType = getMimeType(contentType);
				mimeSubtype = getMimeSubtype(contentType);
				contentDisposition = getContentDisposition(dataHeader);
			}
		}
	}
1227783
private void initializeMe(){
		Long pattern = Long.valueOf(0);
		ioExceptions = StatValueFactory.createStatValue(pattern, "ioexceptions", getSelectedIntervals());
		servletExceptions = StatValueFactory.createStatValue(pattern, "servletExceptions", getSelectedIntervals());
		runtimeExceptions = StatValueFactory.createStatValue(pattern, "runtimeExceptions", getSelectedIntervals());
		addStatValues(ioExceptions, servletExceptions, runtimeExceptions);
	}
956784
private void inspectGetters(Method method)
    {
        String methodName = method.getName();
        int prefixLength = 0;
        if (methodName.startsWith(GET_PREFIX)) {
            prefixLength = GET_PREFIX.length();
        }

        if (methodName.startsWith(IS_PREIX)) {
            prefixLength = IS_PREIX.length();
        }
        if(prefixLength == 0)
        {
            return;
        }

        String name = decapitalize(methodName.substring(prefixLength));
        if(!isValidProperty(name))
        {
            return;
        }

        // Check that the return type is not null or void
        Class propertyType = method.getReturnType();

        if (propertyType == null || propertyType == void.class)
        {
            return;
        }

        // isXXX return boolean
        if (prefixLength == 2)
        {
            if (!(propertyType == boolean.class))
            {
                return;
            }
        }

        // validate parameter types
        Class[] paramTypes = method.getParameterTypes();
        if (paramTypes.length > 1 ||
           (paramTypes.length == 1 && paramTypes[0] != int.class))
        {
            return;
        }

        if (!method.isAnnotationPresent(UriTransient.class) && !"class".equals(name))
        {
            Object value = getValue(method);

            if (method.isAnnotationPresent(VarName.class))
            {
                name = method.getAnnotation(VarName.class).value();
            }
            if (value != null)
            {
                pairs.put(name, value);
            }
        }
    }
394479
private static DataHandler getDataHandlerForString(Event event) {
        try {
            return new DataHandler(new ByteDataSource(event.getContent().getBytes("UTF-8")));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
1292799
private static void generateParserOnXmlCharacters(BindTypeContext context, MethodSpec.Builder methodBuilder,
			String instanceName, String parserName, BindEntity entity) {
		BindTransform bindTransform;
		int count = 0;
		for (BindProperty property : entity.getCollection()) {
			if (property.xmlInfo.xmlType != XmlType.VALUE && property.xmlInfo.xmlType != XmlType.VALUE_CDATA)
				continue;

			count++;
			methodBuilder.beginControlFlow("if (elementName!=null && $L.hasText())", parserName);
			methodBuilder.addCode("// property $L\n", property.getName());
			bindTransform = BindTransformer.lookup(property);
			bindTransform.generateParseOnXml(context, methodBuilder, parserName,
					property.getPropertyType().getTypeName(), "instance", property);
			methodBuilder.endControlFlow();
		}

		if (count == 0) {
			methodBuilder.addCode("// no property is binded to VALUE o CDATA ");
		}
	}
384431
@Override
	protected void processFeatureNames(QualifiedName name, NameAcceptor acceptor) {
		QualifiedName methodName = operatorMapping == null? null : operatorMapping.getMethodName(name);
		if (methodName != null) {
			acceptor.accept(methodName.toString(), 2);
			QualifiedName simpleOperator = operatorMapping.getSimpleOperator(name);
			if (simpleOperator != null) {
				QualifiedName simpleMethodName = operatorMapping.getMethodName(simpleOperator);
				if (simpleMethodName != null) {
					acceptor.accept(simpleMethodName.toString(), 3);
				}
			}
		} else {
			acceptor.accept(name.toString(), 1);
			processAsPropertyNames(name, acceptor);
		}
	}
1157283
@Override
	public void visit(SQLiteDaoDefinition value) throws Exception {
		currentDaoDefinition = value;

		// check if we need to generate or not
		if (value.getElement().getAnnotation(BindDaoMany2Many.class) != null && value.getElement().getAnnotation(BindGeneratedDao.class) == null) {
			return;
		}

		String classTableName = daoName(value);

		PackageElement pkg = elementUtils.getPackageOf(value.getElement());
		String packageName = pkg.isUnnamed() ? "" : pkg.getQualifiedName().toString();

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindDao.class, packageName, classTableName);

		builder = TypeSpec.classBuilder(classTableName).superclass(Dao.class).addSuperinterface(typeName(value.getElement())).addModifiers(Modifier.PUBLIC);

		for (TypeName item : value.implementedInterface) {
			builder.addSuperinterface(item);
		}

		BindTypeContext context = new BindTypeContext(builder, TypeUtility.typeName(packageName, classTableName), Modifier.PRIVATE);
		String entityName = BindDataSourceSubProcessor.generateEntityName(value, value.getEntity());

		// javadoc for class
		builder.addJavadoc("<p>");
		builder.addJavadoc("\nDAO implementation for entity <code>$L</code>, based on interface <code>$L</code>\n", entityName, value.getElement().getSimpleName().toString());
		builder.addJavadoc("</p>\n\n");
		JavadocUtility.generateJavadocGeneratedBy(builder);
		builder.addJavadoc(" @see $T\n", TypeUtility.className(value.getEntityClassName()));
		builder.addJavadoc(" @see $T\n", TypeUtility.className(value.getElement().getQualifiedName().toString()));
		builder.addJavadoc(" @see $T\n", BindTableGenerator.tableClassName(value, value.getEntity()));

		{
			// constructor
			MethodSpec.Builder methodBuilder = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addParameter(BindDaoFactoryBuilder.generateDaoFactoryClassName(value.getParent()),
					"daoFactory");
			methodBuilder.addStatement("super(daoFactory.context())");

			if (value.hasRelations()) {
				methodBuilder.addStatement("this.daoFactory=daoFactory");
				builder.addField(BindDaoFactoryBuilder.generateDaoFactoryClassName(value.getParent()), "daoFactory", Modifier.PRIVATE);
			}

			builder.addMethod(methodBuilder.build());
		}

		// define column typeName set
		for (SQLiteModelMethod item : value.getCollection()) {
			item.accept(this);
		}

		// generate live data support methods
		if (value.hasLiveData()) {
			// method sendEvent
			{
				MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(METHOD_NAME_REGISTRY_EVENT).addModifiers(Modifier.PROTECTED).addParameter(Integer.TYPE, "affectedRows");
				methodBuilder.beginControlFlow("if (affectedRows==0)");
				methodBuilder.addStatement("return");
				methodBuilder.endControlFlow();

				methodBuilder.beginControlFlow("if (_context.isInSession())");
				methodBuilder.addStatement("_context.registrySQLEvent($T.$L)", BindDataSourceBuilder.generateDataSourceName(value.getParent()), value.daoUidName);
				methodBuilder.nextControlFlow("else");
				methodBuilder.addStatement("invalidateLiveData()");
				methodBuilder.endControlFlow();

				builder.addMethod(methodBuilder.build());
			}

			// field liveDatas
			{
				FieldSpec.Builder liveDataBuilder = FieldSpec.builder(ParameterizedTypeName.get(ClassName.get(Collection.class),
						ParameterizedTypeName.get(ClassName.get(WeakReference.class),
								// ParameterizedTypeName.get(ClassName.get(LiveDataHandler.class),
								// WildcardTypeName.subtypeOf(Object.class)))),
								ClassName.get(LiveDataHandler.class))),
						"liveDatas").addModifiers(Modifier.STATIC)
						.initializer(CodeBlock.builder().add("new $T()", ParameterizedTypeName.get(ClassName.get(CopyOnWriteArraySet.class),
								ParameterizedTypeName.get(ClassName.get(WeakReference.class), ClassName.get(LiveDataHandler.class)))).build());
				builder.addField(liveDataBuilder.build());
			}

			// registryLiveData
			{
				// .addParameter(ParameterizedTypeName.get(ClassName.get(LiveDataHandler.class),
				// WildcardTypeName.subtypeOf(Object.class)), "value");
				MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(METHOD_NAME_REGISTRY_LIVE_DATA).addModifiers(Modifier.PROTECTED).addParameter(ClassName.get(LiveDataHandler.class),
						"value");
				methodBuilder.addStatement("liveDatas.add(new $T(value))", ParameterizedTypeName.get(ClassName.get(WeakReference.class), ClassName.get(LiveDataHandler.class)));
				builder.addMethod(methodBuilder.build());
			}

			// invalidateLiveData
			{
				// check datasource and dao package must be the same, otherwise
				// invalidate must be public

				MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(METHOD_NAME_INVALIDATE_LIVE_DATA).addJavadoc("<p>Invalidate livedata.</p>\n\n").addModifiers(Modifier.PUBLIC);
				methodBuilder.beginControlFlow("for ($T item: liveDatas)",
						ParameterizedTypeName.get(ClassName.get(WeakReference.class),
								// ParameterizedTypeName.get(ClassName.get(KriptonLiveDataManager.getInstance().getLiveDataHandlerClazz()),
								// WildcardTypeName.subtypeOf(Object.class))));
								ClassName.get(LiveDataHandler.class)));
				methodBuilder.beginControlFlow("if (item.get()!=null)");
				methodBuilder.addStatement("item.get().invalidate()");
				methodBuilder.endControlFlow();
				methodBuilder.endControlFlow();
				builder.addMethod(methodBuilder.build());
			}

		}

		// generate serializer params
		for (Entry<TypeName, String> item : currentDaoDefinition.managedParams.entrySet()) {
			BindTransformer.checkIfIsInUnsupportedPackage(item.getKey());

			ManagedPropertyPersistenceHelper.generateParamSerializer(context, item.getValue(), item.getKey(), PersistType.BYTE);
			ManagedPropertyPersistenceHelper.generateParamParser(context, item.getValue(), item.getKey(), PersistType.BYTE);
		}

		// generate subject
		if (currentDaoDefinition.getParent().generateRx) {
			ParameterizedTypeName subjectTypeName = ParameterizedTypeName.get(ClassName.get(PublishSubject.class), ClassName.get(SQLiteEvent.class));

			// subject
			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("getSubject").addModifiers(Modifier.PUBLIC);
			methodBuilder.addStatement("return subject").returns(subjectTypeName);
			builder.addMethod(methodBuilder.build());

			// subject instance
			FieldSpec.Builder fieldBuilder = FieldSpec.builder(subjectTypeName, "subject", Modifier.PRIVATE, Modifier.FINAL, Modifier.STATIC).initializer("$T.create()",
					ClassName.get(PublishSubject.class));
			builder.addField(fieldBuilder.build());
		}

		// generate prepared statement cleaner
		{

			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("clearCompiledStatements").addModifiers(Modifier.PUBLIC, Modifier.STATIC).returns(Void.TYPE);
			for (String item : value.preparedStatementNames) {
				methodBuilder.beginControlFlow("if ($L!=null)", item);
				methodBuilder.addStatement("$L.close()", item);
				methodBuilder.addStatement("$L=null", item);
				methodBuilder.endControlFlow();
			}

			builder.addMethod(methodBuilder.build());
		}

		TypeSpec typeSpec = builder.build();

		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);
	}
1068079
public static void generateJavaDocForContentProvider(final SQLiteModelMethod method, MethodSpec.Builder methodBuilder) {

		// javadoc
		String operation = method.jql.operationType.toString();
		methodBuilder.addJavadoc("<h1>Content provider URI ($L operation):</h1>\n", operation);
		methodBuilder.addJavadoc("<pre>$L</pre>\n\n", method.contentProviderUriTemplate.replace("*", "[*]"));

		methodBuilder.addJavadoc("<h2>JQL $L for Content Provider</h2>\n", operation);
		methodBuilder.addJavadoc("<pre>$L</pre>\n\n", method.jql.value);
		methodBuilder.addJavadoc("<h2>SQL $L for Content Provider</h2>\n", operation);
		String sql = JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public String onColumnName(String columnName) {
				SQLProperty tempProperty = currentEntity.get(columnName);
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				return tempProperty.columnName;
			}

			@Override
			public String onColumnAlias(String alias) {
				SQLProperty tempProperty = currentEntity.findPropertyByName(alias);
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, alias);

				return tempProperty.columnName;
			}

		});
		methodBuilder.addJavadoc("<pre>$L</pre>\n\n", sql);

		if (method.contentProviderUriVariables.size() > 0) {
			methodBuilder.addJavadoc("<h3>Path variables defined:</h3>\n<ul>\n");
			for (ContentUriPlaceHolder variable : method.contentProviderUriVariables) {
				methodBuilder.addJavadoc("<li><strong>" + SqlAnalyzer.PARAM_PREFIX + "$L" + SqlAnalyzer.PARAM_SUFFIX + "</strong> at path segment $L</li>\n", variable.value,
						variable.pathSegmentIndex);
			}
			methodBuilder.addJavadoc("</ul>\n\n");
		}

		if (!method.hasDynamicWhereConditions()) {
			methodBuilder.addJavadoc("<p><strong>Dynamic where statement is ignored, due no param with @$L was added.</strong></p>\n\n", BindSqlDynamicWhere.class.getSimpleName());
		}

		methodBuilder.addJavadoc("<p><strong>In URI, * is replaced with [*] for javadoc rapresentation</strong></p>\n\n");
	}
680751
@Requires({
     "types != null",
     "sources != null",
     "types.size() == sources.size()"
  })
  protected void dumpSources(List<TypeModel> types,
                             List<SyntheticJavaFile> sources) {
    Iterator<TypeModel> itType = types.iterator();
    Iterator<SyntheticJavaFile> itFile = sources.iterator();
    while (itType.hasNext() && itFile.hasNext()) {
      TypeModel type = itType.next();
      SyntheticJavaFile file = itFile.next();
      DebugUtils.dump(type.getName().getBinaryName(),
                      file.getCharContent(true).toString().getBytes(),
                      Kind.SOURCE);
    }
  }