/********************************************************************************
 * Copyright (c) 2011-2017 Red Hat Inc. and/or its affiliates and others
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * SPDX-License-Identifier: Apache-2.0
 ********************************************************************************/
package org.eclipse.ceylon.tools.new_;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.eclipse.ceylon.common.FileUtil;
import org.eclipse.ceylon.common.tool.Tool;
import org.eclipse.ceylon.common.tools.CeylonTool;

public abstract class NewSubTool implements Tool {

    private File directory;

    public void setDirectory(File directory) {
        this.directory = directory;
    }

    public File getDirectory() {
        return this.directory;
    }

    void mkBaseDir(File cwd) throws IOException {
        if (directory != null) {
            File actualDir = FileUtil.applyCwd(cwd, directory);
            if (actualDir.exists() && !actualDir.isDirectory()) {
                throw new IOException(Messages.msg("path.exists.and.not.dir", directory));
            } else if (!actualDir.exists()) {
                if (!FileUtil.mkdirs(actualDir)) {
                    throw new IOException(Messages.msg("could.not.mkdir", directory));
                }
            }
        }
    }

    public abstract List<Variable> getVariables();

    public abstract List<Copy> getResources(Environment env);

    @Override
    public void initialize(CeylonTool mainTool) {
    }

    @Override
    public final void run() throws Exception {
        // Projects are never run as tools
        throw new RuntimeException();
    }

}


/*******************************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *******************************************************************************/
package org.apache.ofbiz.widget.renderer;

import java.io.IOException;
import java.util.Map;

import org.apache.ofbiz.widget.model.ModelTree;

/**
 * Widget Library - Tree String Renderer interface
 */
public interface TreeStringRenderer {

    public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth) throws IOException;
    public void renderNodeEnd(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException;
    public void renderLabel(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Label label) throws IOException;
    public void renderLink(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Link link) throws IOException;
    public void renderImage(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Image image) throws IOException;
    public void renderLastElement(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException;
    public ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context);
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.hive.hplsql;

/**
 * Signals and exceptions
 */
public class Signal {
  public enum Type { LEAVE_LOOP, LEAVE_ROUTINE, LEAVE_PROGRAM, SQLEXCEPTION, NOTFOUND, UNSUPPORTED_OPERATION, USERDEFINED };
  Type type;
  String value = "";
  Exception exception = null;

  Signal(Type type, String value) {
    this.type = type;
    this.value = value;
    this.exception = null;
  }

  Signal(Type type, String value, Exception exception) {
    this.type = type;
    this.value = value;
    this.exception = exception;
  }

  /**
   * Get the signal value (message text)
   */
  public String getValue() {
    return value;
  }
}


/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.convert;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Stream;

import org.springframework.core.CollectionFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalGenericConverter;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

/**
 * Converts a {@link Delimiter delimited} String to a Collection.
 *
 * @author Phillip Webb
 */
final class DelimitedStringToCollectionConverter implements ConditionalGenericConverter {

	private final ConversionService conversionService;

	DelimitedStringToCollectionConverter(ConversionService conversionService) {
		Assert.notNull(conversionService, "ConversionService must not be null");
		this.conversionService = conversionService;
	}

	@Override
	public Set<ConvertiblePair> getConvertibleTypes() {
		return Collections.singleton(new ConvertiblePair(String.class, Collection.class));
	}

	@Override
	public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
		return targetType.getElementTypeDescriptor() == null || this.conversionService
				.canConvert(sourceType, targetType.getElementTypeDescriptor());
	}

	@Override
	public Object convert(Object source, TypeDescriptor sourceType,
			TypeDescriptor targetType) {
		if (source == null) {
			return null;
		}
		return convert((String) source, sourceType, targetType);
	}

	private Object convert(String source, TypeDescriptor sourceType,
			TypeDescriptor targetType) {
		Delimiter delimiter = targetType.getAnnotation(Delimiter.class);
		String[] elements = getElements(source,
				(delimiter != null) ? delimiter.value() : ",");
		TypeDescriptor elementDescriptor = targetType.getElementTypeDescriptor();
		Collection<Object> target = createCollection(targetType, elementDescriptor,
				elements.length);
		Stream<Object> stream = Arrays.stream(elements).map(String::trim);
		if (elementDescriptor != null) {
			stream = stream.map((element) -> this.conversionService.convert(element,
					sourceType, elementDescriptor));
		}
		stream.forEach(target::add);
		return target;
	}

	private Collection<Object> createCollection(TypeDescriptor targetType,
			TypeDescriptor elementDescriptor, int length) {
		return CollectionFactory.createCollection(targetType.getType(),
				(elementDescriptor != null) ? elementDescriptor.getType() : null, length);
	}

	private String[] getElements(String source, String delimiter) {
		return StringUtils.delimitedListToStringArray(source,
				Delimiter.NONE.equals(delimiter) ? null : delimiter);
	}

}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.sparql.expr.nodevalue;

import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.sparql.expr.NodeValue ;
import org.apache.jena.sparql.util.FmtUtils ;

public class NodeValueString extends NodeValue
{
    // A plain string, with no language tag, or an xsd:string.

    private String string ;

    public NodeValueString(String str)         { string = str ; }
    public NodeValueString(String str, Node n) { super(n) ; string = str ; }

    @Override
    public boolean isString() { return true ; }

    @Override
    public String getString() { return string ; }

    @Override
    public String asString() { return string ; }

    @Override
    public String toString()
    {
        if ( getNode() != null )
        {
            // Can be a plain string or an xsd:string.
            return FmtUtils.stringForNode(getNode()) ;
        }
        return '"'+string+'"'  ;
    }

    @Override
    protected Node makeNode()
    { return NodeFactory.createLiteral(string) ; }

    @Override
    public void visit(NodeValueVisitor visitor) { visitor.visit(this) ; }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.render.pcl;

import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.intermediate.AbstractIFDocumentHandlerMaker;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandler;

/**
 * Document handler factory for PCL output.
 */
public class PCLDocumentHandlerMaker extends AbstractIFDocumentHandlerMaker {

    private static final String[] MIMES = new String[] {
            MimeConstants.MIME_PCL,
            MimeConstants.MIME_PCL_ALT
    };

    /** {@inheritDoc} */
    public IFDocumentHandler makeIFDocumentHandler(IFContext ifContext) {
        return new PCLDocumentHandler(ifContext);
    }

    /** {@inheritDoc} */
    public boolean needsOutputStream() {
        return true;
    }

    /** {@inheritDoc} */
    public String[] getSupportedMimeTypes() {
        return MIMES;
    }

}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.functor.range;

import org.apache.commons.functor.BinaryFunction;

/**
 * A base class for numeric ranges. The elements within this range must be a
 * Number and Comparable.
 *
 * @param <T> the type of numbers and step that are both a number and comparable
 * @see org.apache.commons.functor.range.IntegerRange
 * @see org.apache.commons.functor.range.LongRange
 * @see org.apache.commons.functor.range.FloatRange
 * @see org.apache.commons.functor.range.DoubleRange
 * @see org.apache.commons.functor.range.CharacterRange
 * @since 0.1
 * @version $Revision$ $Date$
 */
public abstract class NumericRange<T extends Number & Comparable<T>> extends AbstractRange<T, T> {

    /**
     * Construct a new {@link NumericRange}.
     * @param leftEndpoint left endpoint
     * @param rightEndpoint right endpoint
     * @param step increment step
     * @param nextValue function to implement the taking of a step
     */
    protected NumericRange(Endpoint<T> leftEndpoint, Endpoint<T> rightEndpoint, T step,
            BinaryFunction<T, T, T> nextValue) {
        super(leftEndpoint, rightEndpoint, step, nextValue);
    }

    /**
     * {@inheritDoc}
     */
    public boolean contains(T obj) {
        if (obj == null) {
            return false;
        }
        double leftValue = this.getLeftEndpoint().getValue().doubleValue();
        double rightValue = this.getRightEndpoint().getValue().doubleValue();
        boolean includeLeft = this.getLeftEndpoint().getBoundType() == BoundType.CLOSED;
        boolean includeRight = this.getRightEndpoint().getBoundType() == BoundType.CLOSED;
        double step = this.getStep().doubleValue();
        double value = obj.doubleValue();

        double firstValue = 0;
        double lastValue = 0;

        if (step < 0.0) {
            firstValue = includeLeft ? leftValue : leftValue + step;
            lastValue = includeRight ? rightValue : Math.nextUp(rightValue);
            if (value > firstValue || value < lastValue) {
                return false;
            }
        } else {
            firstValue = includeLeft ? leftValue : leftValue + step;
            lastValue = includeRight ? rightValue : rightValue
                                                    - (rightValue - Math
                                                        .nextUp(rightValue));
            if (value < firstValue || value > lastValue) {
                return false;
            }
        }
        return ((value - firstValue) / step + 1) % 1.0 == 0.0;
    }

}


/*

   Derby - Class org.apache.derbyTesting.functionTests.tests.compatibility.helpers.DummyClob

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to you under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

 */
package org.apache.derbyTesting.functionTests.tests.compatibility.helpers;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;

/**
 * A crude Clob implementation for datatype testing.
 */
public class DummyClob
        implements Clob {
    private	String	_contents;

    public	DummyClob(String contents)
    {
        _contents = contents;
    }

    public	InputStream	getAsciiStream()
    {
        try {
            return new ByteArrayInputStream( _contents.getBytes( "UTF-8" ) );
        }
        catch (Exception e) { return null; }
    }

    public	Reader	getCharacterStream()
    {
        return new StringReader(_contents);
    }

    public	String	getSubString( long position, int length )
    {
        return _contents.substring( (int) position -1, length );
    }

    public	long	length() { return (long) _contents.length(); }

    public	long	position( Clob searchstr, long start ) { return 0L; }
    public	long	position( String searchstr, long start ) { return 0L; }

    public	boolean	equals( Object other )
    {
        if ( other == null ) { return false; }
        if ( !( other instanceof Clob ) ) { return false; }

        Clob	that = (Clob) other;

        try {
            if ( this.length() != that.length() ) { return false; }

            InputStream	thisStream = this.getAsciiStream();
            InputStream	thatStream = that.getAsciiStream();

            while( true )
            {
                int		nextByte = thisStream.read();

                if ( nextByte < 0 ) { break; }
                if ( nextByte != thatStream.read() ) { return false; }
            }
        }
        catch (Exception e)
        {
            System.err.println( e.getMessage() );
            e.printStackTrace(System.err);
            return false;
        }

        return true;
    }

    public int setString(long arg0, String arg1) throws SQLException {
        throw new SQLException("not implemented for this test");
    }

    public int setString(long arg0, String arg1, int arg2, int arg3) throws SQLException {
        throw new SQLException("not implemented for this test");
    }

    public OutputStream setAsciiStream(long arg0) throws SQLException {
        throw new SQLException("not implemented for this test");
    }

    public Writer setCharacterStream(long arg0) throws SQLException {
        throw new SQLException("not implemented for this test");
    }

    public void truncate(long arg0) throws SQLException {
        throw new SQLException("not implemented for this test");
    }

    public void free() throws SQLException {
        _contents = null;
    }

    public Reader getCharacterStream(long pos, long length) throws SQLException {
        return new StringReader(
                _contents.substring((int)pos -1, (int)(pos + length)));
    }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.ode.bpel.engine.migration;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.ode.bpel.engine.BpelProcess;
import org.apache.ode.bpel.engine.Contexts;

/**
 * Checks database schema versions and migrates when necessary.
 */
public class MigrationHandler {
    private static final Logger __log = LoggerFactory.getLogger(MigrationHandler.class);

    public static final int CURRENT_SCHEMA_VERSION = 7;

    private Contexts _contexts;
    private List<MigrationLink> migrationLinks = new ArrayList<MigrationLink>() {{
        add(new MigrationLink(1, 2, new Migration[] { new CorrelatorsMigration(),
                                                        new CorrelationKeyMigration() } ));
        add(new MigrationLink(2, 3, new Migration[] { new CorrelationKeySetMigration() } ));
        add(new MigrationLink(4, 3, new Migration[] { new CorrelationKeySetMigration() } ));
        add(new MigrationLink(3, 5, new Migration[] { new CorrelationKeySetDataMigration() } ));
        add(new MigrationLink(5, 6, new Migration[] { new OutstandingRequestsMigration() } ));
        add(new MigrationLink(6, 7, new Migration[] { new IMAManagerMigration() } ));
    }};

    public MigrationHandler(Contexts _contexts) {
        this._contexts = _contexts;
    }

    public boolean migrate(final Set<BpelProcess> registeredProcesses, int migrationTransactionTimeout) {
        if (_contexts.dao.getDataSource() == null) {
            __log.debug("No datasource available, stopping migration. Probably running fully in-memory.");
            return true;
        }

        final int version;
        try {
            version = getDbVersion();
        } catch (Throwable e) {
            __log.info("The ODE_SCHEMA_VERSION database table doesn't exist. Unless you need to migrate your data" +
                    "from a past version, this message can be safely ignored.");
            return false;
        }
        if (version == -1) {
            __log.info("No schema version available from the database, migrations will be skipped.");
            return true;
        }
        if (version == CURRENT_SCHEMA_VERSION) return true;

        try {
            boolean success = _contexts.scheduler.execTransaction(new Callable<Boolean>() {
                public Boolean call() throws Exception {
                    ArrayList<Migration> migrations = new ArrayList<Migration>();
                    findMigrations(version, CURRENT_SCHEMA_VERSION, migrations);
                    if (migrations.size() == 0) {
                        __log.error("Don't know how to migrate from " + version + " to " + CURRENT_SCHEMA_VERSION + ", aborting");
                        return false;
                    } else {
                        boolean success = true;
                        for (Migration mig : migrations) {
                            __log.debug("Running migration " + mig);
                            success = mig.migrate(registeredProcesses, _contexts.dao.getConnection()) && success;
                        }

                        if (!success) _contexts.scheduler.setRollbackOnly();
                        else setDbVersion(CURRENT_SCHEMA_VERSION);
                        return success;
                    }
                }
            }, migrationTransactionTimeout);
            return success;
        } catch (Exception e) {
            __log.error("An error occured while migrating your database to a newer version of ODE, changes have " +
                    "been aborted", e);
            throw new RuntimeException(e);
        }
    }

    private static class MigrationLink {
        int source;
        int target;
        Migration[] migrations;
        public MigrationLink(int source, int target, Migration[] migrations) {
            this.source = source;
            this.target = target;
            this.migrations = migrations;
        }
    }

    /**
     * Attempts to find a way from a source to a target and collects the migrations found along. Assumes
     * a directed graph with no loops. Guarantees that migrations are collected in the proper start-to-end
     * order.
     */
    private boolean findMigrations(int source, int target, List<Migration> ms) {
        List<MigrationLink> l = findLinksTo(target);
        for (MigrationLink link : l) {
            if (link.source == source || findMigrations(source, link.source, ms)) {
                ms.addAll(Arrays.asList(link.migrations));
                return true;
            }
        }
        return false;
    }

    /**
     * Finds all the links with a given target.
     */
    private List<MigrationLink> findLinksTo(int target) {
        ArrayList<MigrationLink> mls = new ArrayList<MigrationLink>();
        for (MigrationLink ml : migrationLinks) {
            if (ml.target == target) mls.add(ml);
        }
        return mls;
    }

    private int getDbVersion() {
        int version = -1;
        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            conn = _contexts.dao.getDataSource().getConnection();
            stmt = conn.prepareStatement("SELECT VERSION FROM ODE_SCHEMA_VERSION");
            rs = stmt.executeQuery();
            if (rs.next()) version = rs.getInt("VERSION");
        } catch (Exception e) {
            // Swallow, we'll just abort based on the version number
        } finally {
            try {
                if (rs != null) rs.close();
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
        return version;
    }

    private void setDbVersion(int version) {
        Connection conn = null;
        Statement stmt = null;
        try {
            conn = _contexts.dao.getDataSource().getConnection();
            stmt = conn.createStatement();
            int res = stmt.executeUpdate("UPDATE ODE_SCHEMA_VERSION SET VERSION = " + version);
            // This should never happen but who knows?
            if (res == 0) throw new RuntimeException("Couldn't update schema version.");
        } catch (Exception e) {
            // Swallow, we'll just abort based on the version number
        } finally {
            try {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
    }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.atlas.lib;

import org.apache.jena.atlas.AtlasException ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;

public class SystemUtils
{
    private static Logger log = LoggerFactory.getLogger(SystemUtils.class.getName());
    // Unfortunately, this tends to cause confusing logging.
    private static boolean logging = false ;

    static public ClassLoader chooseClassLoader()
    {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

        if ( logging && classLoader != null )
            log.trace("Using thread classloader") ;

//        if (classLoader == null)
//        {
//            classLoader = this.getClass().getClassLoader();
//            if ( classLoader != null )
//                logger.trace("Using 'this' classloader") ;
//        }

        if ( classLoader == null )
        {
            classLoader = ClassLoader.getSystemClassLoader() ;
            if ( logging && classLoader != null )
                log.trace("Using system classloader") ;
        }

        if ( classLoader == null )
            throw new AtlasException("Failed to find a classloader") ;
        return classLoader ;
    }

}


/*
 * Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.security.access.intercept.aopalliance;

import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
import org.springframework.security.access.intercept.InterceptorStatusToken;
import org.springframework.security.access.method.MethodSecurityMetadataSource;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * Provides security interception of AOP Alliance based method invocations.
 *

 * The SecurityMetadataSource required by this security interceptor is of
 * type {@link MethodSecurityMetadataSource}. This is shared with the AspectJ based
 * security interceptor (AspectJSecurityInterceptor), since both work with
 * Java Methods.
 *

 * Refer to {@link AbstractSecurityInterceptor} for details on the workflow.
 *
 * @author Ben Alex
 * @author Rob Winch
 */
public class MethodSecurityInterceptor extends AbstractSecurityInterceptor implements
		MethodInterceptor {
	// ~ Instance fields
	// ================================================================================================

	private MethodSecurityMetadataSource securityMetadataSource;

	// ~ Methods
	// ========================================================================================================

	public Class<?> getSecureObjectClass() {
		return MethodInvocation.class;
	}

	/**
	 * This method should be used to enforce security on a MethodInvocation.
	 *
	 * @param mi The method being invoked which requires a security decision
	 *
	 * @return The returned value from the method invocation (possibly modified by the
	 * {@code AfterInvocationManager}).
	 *
	 * @throws Throwable if any error occurs
	 */
	public Object invoke(MethodInvocation mi) throws Throwable {
		InterceptorStatusToken token = super.beforeInvocation(mi);

		Object result;
		try {
			result = mi.proceed();
		}
		finally {
			super.finallyInvocation(token);
		}
		return super.afterInvocation(token, result);
	}

	public MethodSecurityMetadataSource getSecurityMetadataSource() {
		return this.securityMetadataSource;
	}

	public SecurityMetadataSource obtainSecurityMetadataSource() {
		return this.securityMetadataSource;
	}

	public void setSecurityMetadataSource(MethodSecurityMetadataSource newSource) {
		this.securityMetadataSource = newSource;
	}
}


/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.fineract.portfolio.tax.handler;

import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.tax.service.TaxWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@CommandType(entity = "TAXGROUP", action = "UPDATE")
public class UpdateTaxGroupCommandHandler implements NewCommandSourceHandler {

    private final TaxWritePlatformService taxWritePlatformService;

    @Autowired
    public UpdateTaxGroupCommandHandler(final TaxWritePlatformService taxWritePlatformService) {
        this.taxWritePlatformService = taxWritePlatformService;
    }

    @Override
    public CommandProcessingResult processCommand(JsonCommand jsonCommand) {
        return this.taxWritePlatformService.updateTaxGroup(jsonCommand.entityId(), jsonCommand);
    }

}


/*******************************************************************************
 * Copyright (c) 2011, 2016 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.serializer.sequencer;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.nodemodel.ICompositeNode;
import org.eclipse.xtext.nodemodel.INode;

import com.google.inject.ImplementedBy;

/**
 * @author Moritz Eysholdt - Initial contribution and API
 */
@ImplementedBy(SemanticNodeProvider.class)
public interface ISemanticNodeProvider {

	public interface ISemanticNode {
		INode getNode();

		ISemanticNode getFollower();

		AbstractElement getGrammarElement();
	}

	public interface INodesForEObjectProvider {
		ISemanticNode getSemanticNodeForMultiValue(EStructuralFeature feature, int indexInFeature, int indexInNonTransient, Object value);

		ISemanticNode getSemanticNodeForSingelValue(EStructuralFeature feature, Object value);

		ISemanticNode getFirstSemanticNode();

		INode getNodeForMultiValue(EStructuralFeature feature, int indexInFeature, int indexInNonTransient, Object value);

		INode getNodeForSingelValue(EStructuralFeature feature, Object value);
	}

	public class NullNodesForEObjectProvider implements INodesForEObjectProvider {
		@Override
		public INode getNodeForMultiValue(EStructuralFeature feature, int indexInFeature, int indexAmongNonTransient,
				Object value) {
			return null;
		}

		@Override
		public INode getNodeForSingelValue(EStructuralFeature feature, Object value) {
			return null;
		}

		@Override
		public ISemanticNode getSemanticNodeForMultiValue(EStructuralFeature feature, int indexInFeature,
				int indexInNonTransient, Object value) {
			return null;
		}

		@Override
		public ISemanticNode getSemanticNodeForSingelValue(EStructuralFeature feature, Object value) {
			return null;
		}

		@Override
		public ISemanticNode getFirstSemanticNode() {
			return null;
		}
	}

	public INodesForEObjectProvider NULL_NODES_PROVIDER = new NullNodesForEObjectProvider();

	INodesForEObjectProvider getNodesForSemanticObject(EObject semanticObject, ICompositeNode suggestedComposite);

}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.pig.piggybank.storage;

import org.apache.pig.LoadMetadata;
import org.apache.pig.StoreMetadata;
import org.apache.pig.builtin.PigStorage;

/**
 *  This Load/Store Func reads/writes metafiles that allow the schema and
 *  aliases to be determined at load time, saving one from having to manually
 *  enter schemas for pig-generated datasets.
 *
 *  It also creates a ".pig_headers" file that simply lists the delimited aliases.
 *  This is intended to make export to tools that can read files with header
 *  lines easier (just cat the header to your data).
 * @deprecated Use PigStorage with a -schema option instead
 */
@Deprecated
public class PigStorageSchema extends PigStorage implements LoadMetadata, StoreMetadata {
    public PigStorageSchema() {
        this("\t");
    }

    public PigStorageSchema(String delim) {
        super(delim, "-schema");
    }
}


/*
Copyright 2011-2016 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.google.security.zynamics.reil.translators.mips;

import com.google.security.zynamics.reil.ReilHelpers;
import com.google.security.zynamics.reil.ReilInstruction;
import com.google.security.zynamics.reil.translators.IInstructionTranslator;
import com.google.security.zynamics.reil.translators.ITranslationEnvironment;
import com.google.security.zynamics.reil.translators.InternalTranslationException;
import com.google.security.zynamics.reil.translators.TranslationHelpers;
import com.google.security.zynamics.zylib.disassembly.IInstruction;

import java.util.List;

public class ExtTranslator implements IInstructionTranslator {
  @Override
  public void translate(final ITranslationEnvironment environment, final IInstruction instruction,
      final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "ext");

    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    instructions.add(ReilHelpers.createUnknown(baseOffset));
    // TODO final String todo = "";
  }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.accumulo.testing.performance.impl;

import java.io.BufferedReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.accumulo.testing.performance.Result;

import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonStreamParser;

public class Compare {

  private static class TestId {

    final String testClass;
    final String id;

    public TestId(String testClass, String id) {
      this.testClass = testClass;
      this.id = id;
    }

    @Override
    public int hashCode() {
      return Objects.hash(testClass, id);
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj)
        return true;

      if (obj instanceof TestId) {
        TestId other = (TestId) obj;

        return id.equals(other.id) && testClass.equals(other.testClass);
      }

      return false;
    }
  }

  public static void main(String[] args) throws Exception {
    Map<TestId,Double> oldResults = flatten(readReports(args[0]));
    Map<TestId,Double> newResults = flatten(readReports(args[1]));

    for (TestId testId : Sets.union(oldResults.keySet(), newResults.keySet())) {
      Double oldResult = oldResults.get(testId);
      Double newResult = newResults.get(testId);

      if (oldResult == null || newResult == null) {
        System.out.printf("%s %s %.2f %.2f\n", testId.testClass, testId.id, oldResult, newResult);
      } else {
        double change = (newResult - oldResult) / oldResult;
        System.out.printf("%s %s %.2f %.2f %.2f%s\n", testId.testClass, testId.id, oldResult,
            newResult, change * 100, "%");
      }
    }
  }

  static Collection<ContextualReport> readReports(String file) throws Exception {
    try (BufferedReader reader = Files.newBufferedReader(Paths.get(file))) {
      Gson gson = new GsonBuilder().create();
      JsonStreamParser p = new JsonStreamParser(reader);
      List<ContextualReport> rl = new ArrayList<>();

      while (p.hasNext()) {
        JsonElement e = p.next();
        ContextualReport results = gson.fromJson(e, ContextualReport.class);
        rl.add(results);
      }

      return rl;
    }
  }

  private static Map<TestId,Double> flatten(Collection<ContextualReport> results) {
    HashMap<TestId,Double> flattened = new HashMap<>();

    for (ContextualReport cr : results) {
      for (Result r : cr.results) {
        if (r.purpose == Result.Purpose.COMPARISON) {
          flattened.put(new TestId(cr.testClass, r.id), r.data.doubleValue());
        }
      }
    }

    return flattened;
  }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jena.hadoop.rdf.io.input.readers;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.jena.graph.Node ;
import org.apache.jena.hadoop.rdf.io.registry.HadoopRdfIORegistry;
import org.apache.jena.hadoop.rdf.types.QuadWritable;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFLanguages;
import org.apache.jena.sparql.core.Quad ;

/**
 * A record reader that reads RDF from any triples/quads format. Triples are
 * converted into quads in the default graph. This behaviour can be changed by
 * deriving from this class and overriding the {@link #getGraphNode()} method
 *
 *
 *
 */
public class TriplesOrQuadsReader extends AbstractRdfReader<Quad, QuadWritable> {

    @Override
    protected RecordReader<LongWritable, QuadWritable> selectRecordReader(Lang lang) throws IOException {
        if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang))
            throw new IOException(lang.getLabel() + " is not a RDF triples/quads format");

        if (HadoopRdfIORegistry.hasQuadReader(lang)) {
            // Supports quads directly
            return HadoopRdfIORegistry.createQuadReader(lang);
        } else {
            // Try to create a triples reader and wrap upwards into quads
            // This will throw an error if a triple reader is not available
            return new TriplesToQuadsReader(HadoopRdfIORegistry.createTripleReader(lang));
        }
    }

    /**
     * Gets the graph node which represents the graph into which triples will be
     * indicated to belong to when they are converting into quads.
     * <p>
     * Defaults to {@link Quad#defaultGraphNodeGenerated} which represents the
     * default graph
     * </p>
     *
     * @return Graph node
     */
    protected Node getGraphNode() {
        return Quad.defaultGraphNodeGenerated;
    }
}


/*
 * Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.  You may obtain a copy of
 * the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed
 * under the License is distributed on an "AS IS" BASIS, without warranties or
 * conditions of any kind, EITHER EXPRESS OR IMPLIED.  See the License for the
 * specific language governing permissions and limitations under the License.
 */

package com.vmware.xenon.common.jwt;

import com.google.gson.annotations.SerializedName;

/**
 * JSON Web Signature (JWS) Header.
 *
 * See: https://tools.ietf.org/html/rfc7515
 */
public class Header {
    @SerializedName("typ")
    public String type;
    @SerializedName("alg")
    public String algorithm;
    @SerializedName("cty")
    public String contentType;
}


/*******************************************************************************
 * Copyright (c) 2017 Eurotech and/or its affiliates and others
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Eurotech
 *******************************************************************************/
package org.eclipse.kapua.service.datastore.steps;

public class TestTopic {

    private String topic;

    private String clientId;

    private String captured;

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getCaptured() {
        return captured;
    }

    public void setCaptured(String captured) {
        this.captured = captured;
    }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.sis.internal.jaxb.geometry;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.opengis.geometry.Geometry;
import org.apache.sis.xml.Namespaces;

/**
 * JAXB adapter for {@link Geometry}, in order to integrate the value in an element complying with OGC/ISO standard.
 * The geometry element names are usually prefixed by {@code gml:}.
 *
 *
The default implementation does almost nothing. The geometry objects will not
 * create the expected {@link JAXBElement} type. This class is only a hook to be extended by more
 * specialized subclasses in GML modules.

 *
 * @author  Guilhem Legal (Geomatys)
 * @version 0.3
 * @since   0.3
 * @module
 */
public class GM_Object extends XmlAdapter<GM_Object, Geometry> {
    /**
     * The Geometry value covered by a {@code gml:**} element.
     */
    @XmlElementRef(name = "AbstractGeometry", namespace = Namespaces.GML, type = JAXBElement.class)
    protected JAXBElement<? extends Geometry> geometry;

    /**
     * Empty constructor for JAXB and subclasses only.
     */
    public GM_Object() {
    }

    /**
     * Converts an adapter read from an XML stream to the GeoAPI interface which will
     * contains this value. JAXB calls automatically this method at unmarshalling time.
     *
     * @param  value  the adapter for a geometry value.
     * @return an instance of the GeoAPI interface which represents the geometry value.
     */
    @Override
    public final Geometry unmarshal(final GM_Object value) {
        if (value != null) {
            final JAXBElement<? extends Geometry> g = value.geometry;
            if (g != null) {
                return g.getValue();
            }
        }
        return null;
    }

    /**
     * Converts a GeoAPI interface to the appropriate adapter for the way it will be
     * marshalled into an XML file or stream. JAXB calls automatically this method at
     * marshalling time.
     *
     * @param  value  the geometry value, here the interface.
     * @return the adapter for the given value.
     */
    @Override
    public final GM_Object marshal(final Geometry value) {
        if (value == null) {
            return null;
        }
        return wrap(value);
    }

    /**
     * Returns the geometry value to be covered by a {@code gml:**} element.
     * The default implementation returns {@code null} if all cases. Subclasses
     * must override this method in order to provide useful marshalling.
     *
     * @param  value  the value to marshal.
     * @return the adapter which covers the geometry value.
     */
    protected GM_Object wrap(Geometry value) {
        return null;
    }
}


/*
 * Copyright (c) 2011 Google Inc.
 *
 * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0 which accompanies this distribution, and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.google.eclipse.protobuf.junit.core;

import static java.util.regex.Pattern.compile;

import static com.google.eclipse.protobuf.junit.core.GeneratedProtoFiles.ensureParentDirectoryExists;
import static com.google.eclipse.protobuf.junit.core.GeneratedProtoFiles.protoFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author alruiz@google.com (Alex Ruiz)
 */
class FileCreator {
  private static final Pattern CREATE_FILE_PATTERN = compile("// Create file (.*)");

  File createFileFrom(String comment) {
    String fileName = null;
    try (Scanner scanner = new Scanner(comment)) {
	    while (scanner.hasNextLine()) {
	      String line = scanner.nextLine();
	      Matcher matcher = CREATE_FILE_PATTERN.matcher(line);
	      if (!matcher.matches()) {
	        return null;
	      }
	      fileName = matcher.group(1);
	      break;
	    }
    }
    return createFile(fileName, comment);
  }

  private File createFile(String fileName, String contents) {
    ensureParentDirectoryExists();
    File file = protoFile(fileName);
    if (file.isFile()) {
      file.delete();
    }
    Writer out = null;
    try {
      out = new OutputStreamWriter(new FileOutputStream(file));
      out.write(contents);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      closeQuietly(out);
    }
    return file;
  }

  private void closeQuietly(Writer out) {
    if (out == null) {
      return;
    }
    try {
      out.close();
    } catch (IOException e) {}
  }
}


/*
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 3 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 3 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.oracle.truffle.r.runtime.conn;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ProcessBuilder.Redirect;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;

import com.oracle.truffle.r.runtime.RError;
import com.oracle.truffle.r.runtime.conn.ConnectionSupport.AbstractOpenMode;
import com.oracle.truffle.r.runtime.conn.ConnectionSupport.BaseRConnection;
import com.oracle.truffle.r.runtime.conn.ConnectionSupport.ConnectionClass;

public class PipeConnections {

    private static Process executeAndJoin(String command) throws IOException {
        ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", command);
        pb.redirectError(Redirect.INHERIT);
        Process p = pb.start();
        try {
            p.waitFor();
        } catch (InterruptedException e) {
            // TODO not sure how to handle an interrupted exception at this point
        }
        return p;
    }

    public static class PipeRConnection extends BaseRConnection {

        private final String command;

        public PipeRConnection(String command, String open, String encoding) throws IOException {
            super(ConnectionClass.FIFO, open, AbstractOpenMode.Read, encoding);
            this.command = command;
            openNonLazyConnection();
        }

        @Override
        protected void createDelegateConnection() throws IOException {
            final DelegateRConnection delegate;
            switch (getOpenMode().abstractOpenMode) {
                case Read:
                case ReadBinary:
                    delegate = new PipeReadRConnection(this, command);
                    break;
                case Write:
                case WriteBinary:
                    delegate = new PipeWriteConnection(this, command);
                    break;
                case ReadAppend:
                case ReadWrite:
                case ReadWriteBinary:
                case ReadWriteTrunc:
                case ReadWriteTruncBinary:
                    delegate = new PipeReadWriteConnection(this, command);
                    break;
                default:
                    throw RError.nyi(RError.SHOW_CALLER2, "open mode: " + getOpenMode());
            }
            setDelegate(delegate);
        }

        @Override
        public String getSummaryDescription() {
            return command;
        }
    }

    static class PipeReadRConnection extends DelegateReadRConnection {
        private final ByteChannel channel;

        protected PipeReadRConnection(BaseRConnection base, String command) throws IOException {
            super(base);
            Process p = PipeConnections.executeAndJoin(command);
            channel = ConnectionSupport.newChannel(p.getInputStream());
        }

        @Override
        public ByteChannel getChannel() {
            return channel;
        }

        @Override
        public boolean isSeekable() {
            return false;
        }
    }

    private static class PipeWriteConnection extends DelegateWriteRConnection {
        private final ByteChannel channel;

        PipeWriteConnection(BaseRConnection base, String command) throws IOException {
            super(base);
            Process p = PipeConnections.executeAndJoin(command);
            channel = ConnectionSupport.newChannel(p.getOutputStream());
        }

        @Override
        public ByteChannel getChannel() {
            return channel;
        }

        @Override
        public boolean isSeekable() {
            return false;
        }
    }

    private static class PipeReadWriteConnection extends DelegateReadWriteRConnection {

        private final RWChannel channel;

        protected PipeReadWriteConnection(BaseRConnection base, String command) throws IOException {
            super(base);
            Process p = PipeConnections.executeAndJoin(command);
            channel = new RWChannel(p.getInputStream(), p.getOutputStream());
        }

        @Override
        public ByteChannel getChannel() {
            return channel;
        }

        @Override
        public boolean isSeekable() {
            return false;
        }

        private static final class RWChannel implements ByteChannel {
            private final ReadableByteChannel rchannel;
            private final WritableByteChannel wchannel;

            RWChannel(InputStream in, OutputStream out) {
                rchannel = Channels.newChannel(in);
                wchannel = Channels.newChannel(out);
            }

            @Override
            public int read(ByteBuffer dst) throws IOException {
                return rchannel.read(dst);
            }

            @Override
            public boolean isOpen() {
                return rchannel.isOpen() && wchannel.isOpen();
            }

            @Override
            public void close() throws IOException {
                rchannel.close();
                wchannel.close();
            }

            @Override
            public int write(ByteBuffer src) throws IOException {
                return wchannel.write(src);
            }
        }

    }
}


package org.apache.helix.controller.pipeline;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

public class StageException extends Exception {

  public StageException(String message) {
    super(message);
  }

  public StageException(String message, Exception e) {
    super(message, e);
  }
}


/**
 * Copyright (c) Microsoft Corporation
 *

 * All rights reserved.
 *

 * MIT License
 *

 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *

 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *

 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.microsoft.tooling.msservices.serviceexplorer;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;

import java.util.ArrayList;
import java.util.List;

public class NodeAction {
    private String name;
    private boolean enabled = true;
    private List<NodeActionListener> listeners = new ArrayList<NodeActionListener>();
    private Node node; // the node with which this action is associated
    private String iconPath;

    public NodeAction(Node node, String name) {
        this.node = node;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void addListener(NodeActionListener listener) {
        listeners.add(listener);
    }

    public List<NodeActionListener> getListeners() {
        return listeners;
    }

    public void fireNodeActionEvent() {
        if (!listeners.isEmpty()) {
            final NodeActionEvent event = new NodeActionEvent(this);
            for (final NodeActionListener listener : listeners) {
                listener.beforeActionPerformed(event);
                Futures.addCallback(listener.actionPerformedAsync(event), new FutureCallback<Void>() {
                    @Override
                    public void onSuccess(Void aVoid) {
                        listener.afterActionPerformed(event);
                    }

                    @Override
                    public void onFailure(Throwable throwable) {
                        listener.afterActionPerformed(event);
                    }
                });
            }
        }
    }

    public Node getNode() {
        return node;
    }

    public boolean isEnabled() {
        // if the node to which this action is attached is in a
        // "loading" state then we disable the action regardless
        // of what "enabled" is
        return !node.isLoading() && enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getIconPath() {
        return iconPath;
    }

    public void setIconPath(String iconPath) {
        this.iconPath = iconPath;
    }
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.xmlgraphics.java2d;

import java.awt.image.VolatileImage;

/**
 * Adapter to allow subclassing java.awt.GraphicsConfiguration without
 * compilation errors.
 * The version for JDK 1.4 needs to add an override for the abstract
 * createCompatibleVolatileImage() method. It can't be overidden
 * for JDK 1.3 because there is no VolatileImage there.
 *
 */
public abstract class AbstractGraphicsConfiguration extends java.awt.GraphicsConfiguration {

    /**
     * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int)
     * @since JDK 1.4
     */
    public VolatileImage createCompatibleVolatileImage(int width, int height) {
        return null;
    }

    /**
     * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int, int)
     * @since JDK 1.5
     */
    public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) {
        return null;
    }

}


/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package org.apache.ivyde.internal.eclipse.validator;

public interface IValidationReaction {

    void ok();

    void error();
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.asterix.runtime.aggregates.std;

import org.apache.asterix.om.functions.BuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;

public class GlobalSqlStddevPopAggregateDescriptor extends AbstractAggregateFunctionDynamicDescriptor {

    private static final long serialVersionUID = 1L;

    public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
        @Override
        public IFunctionDescriptor createFunctionDescriptor() {
            return new GlobalSqlStddevPopAggregateDescriptor();
        }
    };

    @Override
    public FunctionIdentifier getIdentifier() {
        return BuiltinFunctions.GLOBAL_SQL_STDDEV_POP;
    }

    @Override
    public IAggregateEvaluatorFactory createAggregateEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
        return new IAggregateEvaluatorFactory() {
            private static final long serialVersionUID = 1L;

            @Override
            public IAggregateEvaluator createAggregateEvaluator(final IHyracksTaskContext ctx)
                    throws HyracksDataException {
                return new GlobalSqlStddevAggregateFunction(args, ctx, true, sourceLoc);
            }
        };
    }

}


/*
 * Copyright (c) 2017 the original author or authors.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.eclipse.buildship.core.internal.workspace;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;

import org.gradle.tooling.BuildAction;
import org.gradle.tooling.BuildController;
import org.gradle.tooling.model.gradle.GradleBuild;

/**
 * Build action to query a model for all participants in a composite.
 *
 * @param <T> The requested model type
 * @author Donat Csikos
 */
public final class CompositeModelQuery<T> implements BuildAction<Collection<T>> {

    private static final long serialVersionUID = 1L;

    private final Class<T> modelType;

    public CompositeModelQuery(Class<T> modelType) {
        this.modelType = modelType;
    }

    @Override
    public Collection<T> execute(BuildController controller) {
        Collection<T> models = new ArrayList<>();
        collectRootModels(controller, controller.getBuildModel(), models);
        return models;
    }

    private void collectRootModels(BuildController controller, GradleBuild build, Collection<T> models) {
        models.add(controller.getModel(build.getRootProject(), this.modelType));

        for (GradleBuild includedBuild : build.getIncludedBuilds()) {
            collectRootModels(controller, includedBuild, models);
        }
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.modelType);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        CompositeModelQuery<?> other = (CompositeModelQuery<?>) obj;
        return Objects.equals(this.modelType, other.modelType);
    }

}


/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

package org.apache.isis.core.metamodel.facets.value.imageawt;

import java.awt.Image;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;

public class JavaAwtImageValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Image> {

    public JavaAwtImageValueFacetUsingSemanticsProviderFactory() {
        super();
    }

    @Override
    public void process(final ProcessClassContext processClassContext) {
        final Class<?> type = processClassContext.getCls();
        final FacetHolder holder = processClassContext.getFacetHolder();

        if (type != java.awt.Image.class) {
            return;
        }
        addFacets(new JavaAwtImageValueSemanticsProvider(holder, getContext()));
    }

}


/*
Copyright 2011-2016 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.google.security.zynamics.reil.translators.mips;

import com.google.security.zynamics.reil.OperandSize;
import com.google.security.zynamics.reil.ReilHelpers;
import com.google.security.zynamics.reil.ReilInstruction;
import com.google.security.zynamics.reil.translators.IInstructionTranslator;
import com.google.security.zynamics.reil.translators.ITranslationEnvironment;
import com.google.security.zynamics.reil.translators.InternalTranslationException;
import com.google.security.zynamics.reil.translators.TranslationHelpers;
import com.google.security.zynamics.zylib.disassembly.IInstruction;
import com.google.security.zynamics.zylib.disassembly.IOperandTree;
import com.google.security.zynamics.zylib.general.Triple;

import java.util.List;

public class NorTranslator implements IInstructionTranslator {

  @Override
  public void translate(final ITranslationEnvironment environment, final IInstruction instruction,
      final List<ReilInstruction> instructions) throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "nor");

    final Triple<IOperandTree, IOperandTree, IOperandTree> operands =
        OperandLoader.loadDuplicateFirst(instruction);
    final String targetRegister = operands.first().getRootNode().getChildren().get(0).getValue();
    final String sourceRegister1 = operands.second().getRootNode().getChildren().get(0).getValue();
    final String sourceRegister2 = operands.third().getRootNode().getChildren().get(0).getValue();

    final OperandSize dw = OperandSize.DWORD;

    final long baseOffset = ReilHelpers.toReilAddress(instruction.getAddress()).toLong();
    long offset = baseOffset;

    final String temporaryOrResult = environment.getNextVariableString();

    instructions.add(ReilHelpers.createOr(offset++, dw, sourceRegister1, dw, sourceRegister2, dw,
        temporaryOrResult));
    instructions.add(ReilHelpers.createXor(offset, dw, temporaryOrResult, dw,
        String.valueOf(0xFFFFFFFFL), dw, targetRegister));
  }
}


/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.conscrypt;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.List;

/**
 * Interface for classes that implement certificate pinning for use in {@link TrustManagerImpl}.
 */
@Internal
public interface CertPinManager {
    /**
     * Given a {@code hostname} and a {@code chain} this verifies that the
     * certificate chain includes pinned certificates if pinning is requested
     * for {@code hostname}.
     */
    void checkChainPinning(String hostname, List<X509Certificate> chain)
            throws CertificateException;
}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements. See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.apache.fluo.core.metrics;

import com.google.common.base.Preconditions;
import org.apache.fluo.api.config.FluoConfiguration;

public class MetricNames {

  public static final String METRICS_REPORTER_ID_PROP =
      FluoConfiguration.FLUO_PREFIX + ".metrics.reporter.id";

  // Metrics prefixes for 'default' metrics
  public static final String CLASS_PREFIX = FluoConfiguration.FLUO_PREFIX + ".class";
  public static final String SYSTEM_PREFIX = FluoConfiguration.FLUO_PREFIX + ".system";

  // Metrics prefix for 'application' metrics
  public static final String APPLICATION_PREFIX = FluoConfiguration.FLUO_PREFIX + ".app";

  private final String txLockWaitTime;
  private final String txExecTime;
  private final String txWithCollision;
  private final String txCollisions;
  private final String txEntriesSet;
  private final String txEntriesRead;
  private final String txLocksTimedOut;
  private final String txLocksDead;
  private final String txStatusPrefix;
  private final String txCommitting;

  private final String notificationsQueued;

  private final String oracleResponseTime;
  private final String oracleClientStamps;
  private final String oracleServerStamps;

  public MetricNames(String metricsReporterId, String appName) {
    Preconditions.checkArgument(!appName.contains("."),
        "Fluo App name should not contain '.': " + appName);
    Preconditions.checkArgument(!metricsReporterId.contains("."),
        "Metrics Reporter ID should not contain '.': " + metricsReporterId);

    // Metrics reported for a specific class
    // FORMAT: fluo.class.APPLICATION.REPORTER_ID.METRIC.CLASS
    final String classMetric = CLASS_PREFIX + "." + appName + "." + metricsReporterId + ".";
    txLockWaitTime = classMetric + "tx_lock_wait_time";
    txExecTime = classMetric + "tx_execution_time";
    txWithCollision = classMetric + "tx_with_collision";
    txCollisions = classMetric + "tx_collisions";
    txEntriesSet = classMetric + "tx_entries_set";
    txEntriesRead = classMetric + "tx_entries_read";
    txLocksTimedOut = classMetric + "tx_locks_timedout";
    txLocksDead = classMetric + "tx_locks_dead";
    txStatusPrefix = classMetric + "tx_status_"; // status appended to metric name

    // System-wide metrics
    // FORMAT: fluo.system.APPLICATION.REPORTER_ID.METRIC
    final String systemMetric = SYSTEM_PREFIX + "." + appName + "." + metricsReporterId + ".";
    txCommitting = systemMetric + "transactor_committing";
    notificationsQueued = systemMetric + "worker_notifications_queued";
    oracleResponseTime = systemMetric + "oracle_response_time";
    oracleClientStamps = systemMetric + "oracle_client_stamps";
    oracleServerStamps = systemMetric + "oracle_server_stamps";
  }

  public String getTxLockWaitTime(String className) {
    return txLockWaitTime + "." + className;
  }

  public String getTxExecTime(String className) {
    return txExecTime + "." + className;
  }

  public String getTxWithCollision(String className) {
    return txWithCollision + "." + className;
  }

  public String getTxCollisions(String className) {
    return txCollisions + "." + className;
  }

  public String getTxEntriesSet(String className) {
    return txEntriesSet + "." + className;
  }

  public String getTxEntriesRead(String className) {
    return txEntriesRead + "." + className;
  }

  public String getTxLocksTimedout(String className) {
    return txLocksTimedOut + "." + className;
  }

  public String getTxLocksDead(String className) {
    return txLocksDead + "." + className;
  }

  public String getTxStatus(String status, String className) {
    return txStatusPrefix + status + "." + className;
  }

  public String getNotificationQueued() {
    return notificationsQueued;
  }

  public String getOracleResponseTime() {
    return oracleResponseTime;
  }

  public String getOracleClientStamps() {
    return oracleClientStamps;
  }

  public String getOracleServerStamps() {
    return oracleServerStamps;
  }

  public String getCommitsProcessing() {
    return txCommitting;
  }
}


/*
 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 3 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 3 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 3 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.oracle.truffle.r.nodes.control;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.r.nodes.function.visibility.SetVisibilityNode;
import com.oracle.truffle.r.nodes.unary.ConvertBooleanNode;
import com.oracle.truffle.r.runtime.ArgumentsSignature;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxCall;
import com.oracle.truffle.r.runtime.nodes.RSyntaxElement;
import com.oracle.truffle.r.runtime.nodes.RSyntaxLookup;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;

public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, RSyntaxCall {

    @Child private LoopNode loop;
    @Child private SetVisibilityNode visibility = SetVisibilityNode.create();

    public WhileNode(SourceSection src, RSyntaxLookup operator, RSyntaxNode condition, RSyntaxNode body) {
        super(src, operator);
        this.loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(this, ConvertBooleanNode.create(condition), body.asRNode()));
    }

    @Override
    public Object execute(VirtualFrame frame) {
        loop.executeLoop(frame);
        visibility.execute(frame, false);
        return RNull.instance;
    }

    private static final class WhileRepeatingNode extends AbstractRepeatingNode {

        @Child private ConvertBooleanNode condition;

        private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();
        private final BranchProfile normalBlock = BranchProfile.create();
        private final BranchProfile breakBlock = BranchProfile.create();
        private final BranchProfile nextBlock = BranchProfile.create();

        // only used for toString
        private final WhileNode whileNode;

        WhileRepeatingNode(WhileNode whileNode, ConvertBooleanNode condition, RNode body) {
            super(body);
            this.whileNode = whileNode;
            this.condition = condition;
            // pre-initialize the profile so that loop exits to not deoptimize
            conditionProfile.profile(false);
        }

        @Override
        public boolean executeRepeating(VirtualFrame frame) {
            try {
                if (conditionProfile.profile(condition.executeByte(frame) == RRuntime.LOGICAL_TRUE)) {
                    body.voidExecute(frame);
                    normalBlock.enter();
                    return true;
                } else {
                    return false;
                }
            } catch (BreakException e) {
                breakBlock.enter();
                return false;
            } catch (NextException e) {
                nextBlock.enter();
                return true;
            }
        }

        @Override
        public String toString() {
            return whileNode.toString();
        }
    }

    @Override
    public RSyntaxElement[] getSyntaxArguments() {
        WhileRepeatingNode repeatingNode = (WhileRepeatingNode) loop.getRepeatingNode();
        return new RSyntaxElement[]{repeatingNode.condition.asRSyntaxNode(), repeatingNode.body.asRSyntaxNode()};
    }

    @Override
    public ArgumentsSignature getSyntaxSignature() {
        return ArgumentsSignature.empty(2);
    }
}


/**
 * Copyright (c) 2018 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * https://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.vorto.codegen.api;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.vorto.core.api.model.datatype.Entity;
import org.eclipse.vorto.core.api.model.datatype.Enum;
import org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType;
import org.eclipse.vorto.core.api.model.datatype.Type;
import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel;
import org.eclipse.vorto.core.api.model.functionblock.RefParam;
import org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType;
import org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty;
import org.eclipse.vorto.core.api.model.informationmodel.InformationModel;

/**
 * Generator task that traverses all types used in an information model and generates their platform
 * specific representations
 *
 * @author Alexander Edelmann - Robert Bosch (SEA) Pte. Ltd.
 *
 */
public class DatatypeGeneratorTask implements ICodeGeneratorTask<InformationModel> {

  private IFileTemplate<Entity> entityTemplate;
  private IFileTemplate<Enum> enumTemplate;

  public DatatypeGeneratorTask(IFileTemplate<Entity> entityTemplate,
      IFileTemplate<Enum> enumTemplate) {
    this.entityTemplate = entityTemplate;
    this.enumTemplate = enumTemplate;
  }

  @Override
  public void generate(InformationModel ctx, InvocationContext context, IGeneratedWriter writer) {
    Set<Type> allTypesUsedInModel = new HashSet<>();
    for (FunctionblockProperty prop : ctx.getProperties()) {
      allTypesUsedInModel.addAll(getTypes(prop.getType()));
    }

    for (Type type : allTypesUsedInModel) {
      if (type instanceof Entity) {
        writer.write(new Generated(entityTemplate.getFileName((Entity) type),
            entityTemplate.getPath((Entity) type),
            entityTemplate.getContent((Entity) type, context)));
      } else if (type instanceof Enum) {
        writer.write(new Generated(enumTemplate.getFileName((Enum) type),
            enumTemplate.getPath((Enum) type), enumTemplate.getContent((Enum) type, context)));
      }
    }
  }

  private static Set<Type> getTypes(FunctionblockModel model) {
    Set<Type> allTypes = new LinkedHashSet<>();
    TreeIterator<EObject> iterator = model.eAllContents();
    while (iterator.hasNext()) {
      EObject current = iterator.next();
      if (current instanceof RefParam) {
        addTypeAndReferences(((RefParam) current).getType(), allTypes);
      } else if (current instanceof ReturnObjectType) {
        addTypeAndReferences(((ReturnObjectType) current).getReturnType(), allTypes);
      } else if (current instanceof ObjectPropertyType) {
        addTypeAndReferences(((ObjectPropertyType) current).getType(), allTypes);
      }
    }
    return allTypes;
  }

  private static void addTypeAndReferences(Type type, Set<Type> container) {
    if (!container.contains(type)) {
      container.add(type);
      Set<Type> references = getTypesOfType(type, container);
      container.addAll(references);
    }
  }

  private static Set<Type> getTypesOfType(Type type, Set<Type> container) {
    TreeIterator<EObject> iterator = type.eAllContents();
    while (iterator.hasNext()) {
      EObject current = iterator.next();
      if (current instanceof ObjectPropertyType) {
        if (!container.contains(current)) {
          container.add(((ObjectPropertyType) current).getType());
          Set<Type> moreTypes = getTypesOfType(((ObjectPropertyType) current).getType(), container);
          container.addAll(moreTypes);
        }

      }
    }

    return container;
  }
}


package org.apache.taverna.workbench.models.graph;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * A graph model of a dataflow.
 *
 * @author David Withers
 */
public class Graph extends GraphShapeElement {
	public enum Alignment {
		HORIZONTAL, VERTICAL
	}

	private List<GraphNode> nodes = new ArrayList<>();
	private Set<GraphEdge> edges = new HashSet<>();
	private Set<Graph> subgraphs = new HashSet<>();
	private Alignment alignment = Alignment.VERTICAL;

	/**
	 * Constructs a Graph that uses the specified GraphEventManager to handle
	 * any user generated events on GraphElements.
	 *
	 * @param eventManager
	 */
	public Graph(GraphController graphController) {
		super(graphController);
	}

	/**
	 * Adds an edge to the Graph and sets its parent to be this Graph.
	 *
	 * @param edge
	 *            the edge to add
	 */
	public void addEdge(GraphEdge edge) {
		edge.setParent(this);
		edges.add(edge);
	}

	/**
	 * Adds a node to the Graph and sets its parent to be this Graph.
	 *
	 * @param node
	 *            the node to add
	 */
	public void addNode(GraphNode node) {
		node.setParent(this);
		nodes.add(node);
	}

	/**
	 * Adds a subgraph to the Graph and sets its parent to be this Graph.
	 *
	 * @param subgraph
	 *            the subgraph to add
	 */
	public void addSubgraph(Graph subgraph) {
		subgraph.setParent(this);
		subgraphs.add(subgraph);
	}

	/**
	 * Returns the alignment of the Graph.
	 *
	 * @return the alignment of the Graph
	 */
	public Alignment getAlignment() {
		return alignment;
	}

	/**
	 * Returns the edges contained in the Graph.
	 *
	 * @return the edges contained in the Graph
	 */
	public Set<GraphEdge> getEdges() {
		return Collections.unmodifiableSet(edges);
	}

	/**
	 * Returns the nodes contained in the Graph.
	 *
	 * @return the nodes contained in the Graph
	 */
	public List<GraphNode> getNodes() {
		return Collections.unmodifiableList(nodes);
	}

	/**
	 * Returns the subgraphs contained in the Graph.
	 *
	 * @return the subgraphs contained in the Graph
	 */
	public Set<Graph> getSubgraphs() {
		return Collections.unmodifiableSet(subgraphs);
	}

	/**
	 * Removes an edge from the Graph.
	 *
	 * @param edge
	 *            the edge to remove
	 * @return true if the edge is removed from the Graph
	 */
	public boolean removeEdge(GraphEdge edge) {
		return edges.remove(edge);
	}

	/**
	 * Removes a node from the Graph.
	 *
	 * @param node
	 *            the node to remove
	 * @return true if the node is removed from the Graph
	 */
	public boolean removeNode(GraphNode node) {
		return nodes.remove(node);
	}

	/**
	 * Removes a subgraph from the Graph.
	 *
	 * @param subgraph
	 *            the subgraph to remove
	 * @return true if the subgraph is removed from the Graph
	 */
	public boolean removeSubgraph(Graph subgraph) {
		return subgraphs.remove(subgraph);
	}

	/**
	 * Sets the alignment of the Graph.
	 *
	 * @param alignment
	 *            the new alignment
	 */
	public void setAlignment(Alignment alignment) {
		this.alignment = alignment;
	}
}


package example.service;

import example.repo.Customer758Repository;

import org.springframework.stereotype.Service;

@Service
public class Customer758Service {
	public Customer758Service(Customer758Repository repo) {
	}
}


/*
 * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.ibm.cloud.objectstorage.services.s3.transfer.internal;

import com.ibm.cloud.objectstorage.event.ProgressEvent;
import com.ibm.cloud.objectstorage.event.SyncProgressListener;
import com.ibm.cloud.objectstorage.services.s3.transfer.TransferProgress;

public class TransferProgressUpdatingListener extends SyncProgressListener {
    private final TransferProgress transferProgress;

    public TransferProgressUpdatingListener(TransferProgress transferProgress) {
        this.transferProgress = transferProgress;
    }

    public void progressChanged(ProgressEvent progressEvent) {
        long bytes = progressEvent.getBytesTransferred();
        if (bytes == 0)
            return; // only interested in non-zero bytes
        transferProgress.updateProgress(bytes);
    }
}