text:
/**
 *
 */
package br.com.cams7.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.net.URL;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;

import br.com.cams7.app.BaseRepository;
import br.com.cams7.domain.BaseEntity;

/**
 * @author cams7
 *
 */
public final class AppUtil {
	public static URL getURLFile(Class<?> classType, String fileName) {
		URL fileURL = classType.getClassLoader().getResource(fileName);
		return fileURL;
	}

	public static Properties getPropertiesFile(Class<?> classType,
			String fileName) throws AppException {
		URL fileURL = getURLFile(classType, fileName);

		InputStream in = null;
		try {
			in = fileURL.openStream();
			Reader reader = new InputStreamReader(in, "UTF-8");

			Properties properties = new Properties();

			try {
				properties.load(reader);
			} finally {
				reader.close();
			}

			return properties;
		} catch (IOException e) {
			throw new AppException(e.getCause());
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

	}

	public static Class<?> getType(Class<?> type, byte argumentNumber) {
		Class<?> returnType = (Class<?>) ((ParameterizedType) type
				.getGenericSuperclass()).getActualTypeArguments()[argumentNumber];
		return returnType;
	}

	public static Class<?> getType(Object object, byte argumentNumber) {
		Class<?> type = getType(object.getClass(), argumentNumber);
		return type;
	}

	public static <E extends BaseEntity<ID>, ID extends Serializable> E getNewEntity(
			Class<E> entityType) throws AppException {
		try {
			E entity = entityType.newInstance();
			return entity;
		} catch (InstantiationException | IllegalAccessException e) {
			throw new AppException(e.getMessage(), e.getCause());
		}
	}

	public static <E extends BaseEntity<ID>, ID extends Serializable> E getNewEntity(
			Class<E> entityType, ID id) throws AppException {

		E entity = getNewEntity(entityType);
		entity.setId(id);

		return entity;
	}

	public static boolean isBoolean(Class<?> type) {
		return type.equals(Boolean.class) || type.equals(Boolean.TYPE);
	}

	private static boolean isInteger(Class<?> type) {
		if (type.equals(Byte.class) || type.equals(Byte.TYPE))
			return true;

		if (type.equals(Short.class) || type.equals(Short.TYPE))
			return true;

		if (type.equals(Integer.class) || type.equals(Integer.TYPE))
			return true;

		if (type.equals(Long.class) || type.equals(Long.TYPE))
			return true;

		return false;
	}

	private static boolean isFloat(Class<?> type) {
		if (type.equals(Float.class) || type.equals(Float.TYPE))
			return true;

		if (type.equals(Double.class) || type.equals(Double.TYPE))
			return true;

		return false;
	}

	public static boolean isNumber(Class<?> type) {
		if (isInteger(type))
			return true;

		if (isFloat(type))
			return true;

		return false;
	}

	public static boolean isDate(Class<?> type) {
		return type.equals(Date.class);
	}

	public static boolean isEnum(Class<?> type) {
		return type.isEnum();
	}

	private static String getCorrectValue(String value) {
		if (value == null || value.isEmpty())
			return null;

		return value.trim();
	}

	public static Map<Integer, Short>[] getDate(String value) {
		value = getCorrectValue(value);

		if (value == null)
			return null;

		final String REGEX_HOUR_MINUTE_SECOND = "(([01][0-9]|2[0-3]|[\\*])[:]([0-5][0-9]|[\\*])([:]([0-5][0-9]|[\\*]))?)";
		// TODO Ano bissexto não e valido
		final String REGEX_DATE = "(((((((0[1-9]|1[0-9]|2[0-8]|[\\*])[\\/])?(0[1-9]|1[012]|[\\*]))|((29|30|31)[\\/](0[13578]|1[02]|[\\*]))|((29|30)[\\/](0[4,6,9]|11)))[\\/])?((19|20)\\d{2}|[\\*]))";
		final String REGEX_DATETIME = "(" + REGEX_DATE + ")([ \t]"
				+ REGEX_HOUR_MINUTE_SECOND + ")?)";
		final String REGEX_BETWEEN_TWO_DATES = "(^(" + REGEX_DATETIME + "(\\-"
				+ REGEX_DATETIME + ")?)$)";

		if (!value.matches(REGEX_BETWEEN_TWO_DATES))
			return null;

		String[] stringDates = value.split("\\-");

		@SuppressWarnings("unchecked")
		Map<Integer, Short>[] between = new Map[stringDates.length];

		for (byte i = 0; i < stringDates.length; i++) {
			String[] dateAndTime = stringDates[i].split(" ");

			String date = dateAndTime[0];
			String time = dateAndTime.length > 1 ? dateAndTime[1] : null;

			Map<Integer, Short> map = new HashMap<Integer, Short>();

			String[] dateValues = date.split("\\/");

			String year = dateValues[dateValues.length - 1];
			if (!"*".equals(year))
				map.put(Calendar.YEAR, Short.valueOf(year));

			if (dateValues.length > 1) {
				String month = dateValues[dateValues.length - 2];
				if (!"*".equals(month))
					map.put(Calendar.MONTH, Short.valueOf(month));

				if (dateValues.length == 3) {
					String day = dateValues[dateValues.length - 3];

					if (!"*".equals(day))
						map.put(Calendar.DAY_OF_MONTH, Short.valueOf(day));
				}
			}

			if (time != null) {
				String[] timeValues = time.split("\\:");
				String hour = timeValues[0];
				String minute = timeValues[1];

				if (!"*".equals(hour))
					map.put(Calendar.HOUR_OF_DAY, Short.valueOf(hour));

				if (!"*".equals(minute))
					map.put(Calendar.MINUTE, Short.valueOf(minute));

				if (timeValues.length == 3) {
					String second = timeValues[2];
					if (!"*".equals(second))
						map.put(Calendar.SECOND, Short.valueOf(second));
				}
			}

			between[i] = map;

		}

		return between;

	}

	public static Calendar[] getDate(Map<Integer, Short>[] between) {
		if (between == null)
			return null;

		GregorianCalendar[] dates = new GregorianCalendar[between.length];

		boolean isTwoDates = between.length == 2;

		Locale ptBr = new Locale("pt", "BR"); // Locale para o Brasil

		dates[0] = new GregorianCalendar(ptBr);
		dates[0].set(Calendar.YEAR, 1900);
		dates[0].set(Calendar.MONTH, 0);
		dates[0].set(Calendar.DAY_OF_MONTH, 1);
		dates[0].set(Calendar.HOUR_OF_DAY, 0);
		dates[0].set(Calendar.MINUTE, 0);
		dates[0].set(Calendar.SECOND, 0);
		dates[0].set(Calendar.MILLISECOND, 0);

		if (isTwoDates) {
			dates[1] = new GregorianCalendar(ptBr);
			dates[1].set(Calendar.YEAR, 2099);
			dates[1].set(Calendar.MONTH, 11);
			dates[1].set(Calendar.DAY_OF_MONTH, 31);
			dates[1].set(Calendar.HOUR_OF_DAY, 23);
			dates[1].set(Calendar.MINUTE, 59);
			dates[1].set(Calendar.SECOND, 59);
			dates[1].set(Calendar.MILLISECOND, 999);
		}

		for (byte i = 0; i < between.length; i++) {
			if (between[i].get(Calendar.YEAR) != null)
				dates[i].set(Calendar.YEAR, between[i].get(Calendar.YEAR));

			if (between[i].get(Calendar.MONTH) != null) {
				int month = between[i].get(Calendar.MONTH);

				if (i == 1) {
					if (month == 4 || month == 6 || month == 9 || month == 11)
						dates[i].set(Calendar.DAY_OF_MONTH, 30);
					else if (month == 2)
						dates[i].set(Calendar.DAY_OF_MONTH, dates[i]
								.isLeapYear(dates[i].get(Calendar.YEAR)) ? 29
								: 28);
				}
				dates[i].set(Calendar.MONTH, month - 1);
			}

			if (between[i].get(Calendar.DAY_OF_MONTH) != null)
				dates[i].set(Calendar.DAY_OF_MONTH,
						between[i].get(Calendar.DAY_OF_MONTH));

			if (between[i].get(Calendar.HOUR_OF_DAY) != null)
				dates[i].set(Calendar.HOUR_OF_DAY,
						between[i].get(Calendar.HOUR_OF_DAY));

			if (between[i].get(Calendar.MINUTE) != null)
				dates[i].set(Calendar.MINUTE, between[i].get(Calendar.MINUTE));

			if (between[i].get(Calendar.SECOND) != null)
				dates[i].set(Calendar.SECOND, between[i].get(Calendar.SECOND));
		}

		return dates;
	}

	public static <K, V> boolean equalMaps(Map<K, V> map1, Map<K, V> map2) {

		if (map1 == null && map2 == null)
			return true;

		if ((map1 == null && map2 != null) || (map1 != null && map2 == null))
			return false;

		if (map1.isEmpty() && map2.isEmpty())
			return true;

		if ((map1.isEmpty() && !map2.isEmpty())
				|| (!map1.isEmpty() && map2.isEmpty()))
			return false;

		boolean isEquals = true;

		if (map1.size() == map2.size()) {
			keyMap: for (K key : map1.keySet()) {
				if (!map2.containsKey(key)) {
					isEquals = false;
					break;
				}

				V value1 = map1.get(key);
				V value2 = map2.get(key);

				if (value1 instanceof Object[] && value2 instanceof Object[]) {
					Object[] array1 = (Object[]) value1;
					Object[] array2 = (Object[]) value2;

					if (array1.length != array2.length) {
						isEquals = false;
						break;
					}

					List<?> list = Arrays.asList(array1);

					for (Object value : array2) {
						if (!list.contains(value)) {
							isEquals = false;
							break keyMap;
						}
					}

				} else if (!value1.equals(value2)) {
					isEquals = false;
					break;
				}

			}
		} else
			isEquals = false;

		return isEquals;
	}

	public static <K, V> Map<K, V> removeEmptyArray(Map<K, V> map) {
		if (map != null && !map.isEmpty()) {
			Iterator<Map.Entry<K, V>> i = map.entrySet().iterator();

			while (i.hasNext()) {
				Map.Entry<K, V> entry = i.next();
				V value = entry.getValue();

				if ((value instanceof Object[])
						&& ((Object[]) value).length == 0)
					i.remove();
			}

		}

		return map;
	}

	public static String getExceptionMessage(String message) {
		String[] array = message.split(":");
		message = array[array.length - 1];
		return message.trim();
	}

	public static Map<String, String> getErrorResponse(String exceptionMessage) {
		Map<String, String> response = new HashMap<>();
		response.put("error", exceptionMessage);
		return response;
	}

	public static BaseRepository<?, ?> getNewDataSource(Class<?> dsType)
			throws AppException {
		try {
			BaseRepository<?, ?> repository = (BaseRepository<?, ?>) dsType
					.newInstance();
			return repository;
		} catch (InstantiationException | IllegalAccessException e) {
			throw new AppException(e.getMessage(), e.getCause());
		}
	}

}


text: ./antlr4.sh -o src/main/java/profiler -package profiler Java.g4

redpajama_set_name: RedPajamaGithub


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Jb. wiss. Bot. 6(3): 277 (1863)

#### Original name
Syzygites ampelinus Hildebr., 1863

### Remarks
null


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.acme</groupId>
        <artifactId>my-ext-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>my-ext</artifactId>
    <name>My Ext - Runtime</name>

    <dependencies>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-extension-maven-plugin</artifactId>
                <version>${quarkus.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>extension-descriptor</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <deployment>\${project.groupId}:\${project.artifactId}-deployment:\${project.version}
                            </deployment>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>io.quarkus</groupId>
                            <artifactId>quarkus-extension-processor</artifactId>
                            <version>${quarkus.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


text:
package org.japo.java.main;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 *
 * @author 2016 - Adrián
 */
public class Main {
    public static void main(String[] args) {

        int dia;
        int mes;
        int anyo;

        //
        GregorianCalendar gc = new GregorianCalendar();

        // Hora
        dia = gc.get(Calendar.DAY_OF_MONTH);
        mes = gc.get(Calendar.MONTH) + 1;
        anyo = gc.get(Calendar.YEAR);

        System.out.printf("Fecha del sistema ...: %02d/%02d/%d\n", dia, mes, anyo);

    }

}


text:
using System;

using EnergonSoftware.Core.Util.Crypt;

namespace EnergonSoftware.Core.Util
{
    /// <summary>
    /// A number used once
    /// </summary>
    [Serializable]
    public sealed class Nonce
    {
        /// <summary>
        /// Gets the nonce realm.
        /// </summary>
        /// <value>
        /// The nonce realm.
        /// </value>
        public string Realm { get; }

        /// <summary>
        /// Gets the expiration time.
        /// </summary>
        /// <value>
        /// The expiration time.
        /// </value>
        public TimeSpan Expiry { get; } = TimeSpan.MinValue;

        /// <summary>
        /// Gets the nonce value.
        /// </summary>
        /// <value>
        /// The nonce value.
        /// </value>
        public string NonceValue { get; }

        /// <summary>
        /// Gets the nonce hash.
        /// </summary>
        /// <value>
        /// The nonce hash.
        /// </value>
        public string NonceHash { get; private set; }

        /// <summary>
        /// Gets the nonce creation time.
        /// </summary>
        /// <value>
        /// The nonce creation time.
        /// </value>
        public DateTime CreationTime { get; } = DateTime.Now;

        /// <summary>
        /// Gets a value indicating whether this <see cref="Nonce"/> is expired.
        /// </summary>
        /// <value>
        ///   <c>true</c> if expired; otherwise, <c>false</c>.
        /// </value>
        public bool Expired => Expiry > TimeSpan.Zero && (DateTime.Now - CreationTime) > Expiry;

        /// <summary>
        /// Initializes a new instance of the <see cref="Nonce" /> class.
        /// </summary>
        /// <param name="realm">The nonce realm.</param>
        /// <param name="expiryMs">The expiration time in milliseconds.</param>
        public Nonce(string realm, int expiryMs)
            : this()
        {
            Realm = realm;
            Expiry = TimeSpan.FromMilliseconds(expiryMs);
            NonceValue = $"{CreationTime.GetTicksMs()}:${Realm}";
            NonceHash = new SHA512().HashHexAsync(NonceValue).Result;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Nonce"/> class.
        /// </summary>
        /// <param name="realm">The nonce realm.</param>
        /// <param name="nonce">The nonce.</param>
        /// <param name="expiryMs">The expiration time in milliseconds.</param>
        public Nonce(string realm, string nonce, int expiryMs)
            : this()
        {
            Realm = realm;
            Expiry = TimeSpan.FromMilliseconds(expiryMs);
            NonceValue = nonce;
            NonceHash = new SHA512().HashHexAsync(NonceValue).Result;

            int idx = NonceValue.IndexOf(":", StringComparison.InvariantCultureIgnoreCase);
            CreationTime = DateTimeExtensions.DateTimeFromTicksMs(int.Parse(NonceValue.Substring(0, idx)));
        }

        private Nonce()
        {
        }
    }
}


text:
package org.apache.cassandra.db.rows;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Comparator;
import java.util.List;

import org.apache.cassandra.config.CFMetaData;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.filter.ClusteringIndexFilter;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.io.sstable.IndexInfo;
import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.io.sstable.metadata.StatsMetadata;
import org.apache.cassandra.thrift.ThriftResultsMerger;
import org.apache.cassandra.utils.IteratorWithLowerBound;

/**
 * An unfiltered row iterator with a lower bound retrieved from either the global
 * sstable statistics or the row index lower bounds (if available in the cache).
 * Before initializing the sstable unfiltered row iterator, we return an empty row
 * with the clustering set to the lower bound. The empty row will be filtered out and
 * the result is that if we don't need to access this sstable, i.e. due to the LIMIT conditon,
 * then we will not. See CASSANDRA-8180 for examples of why this is useful.
 */
public class UnfilteredRowIteratorWithLowerBound extends LazilyInitializedUnfilteredRowIterator implements IteratorWithLowerBound<Unfiltered>
{
    private final SSTableReader sstable;
    private final ClusteringIndexFilter filter;
    private final ColumnFilter selectedColumns;
    private final boolean isForThrift;
    private final int nowInSec;
    private final boolean applyThriftTransformation;
    private ClusteringBound lowerBound;
    private boolean firstItemRetrieved;

    public UnfilteredRowIteratorWithLowerBound(DecoratedKey partitionKey,
                                               SSTableReader sstable,
                                               ClusteringIndexFilter filter,
                                               ColumnFilter selectedColumns,
                                               boolean isForThrift,
                                               int nowInSec,
                                               boolean applyThriftTransformation)
    {
        super(partitionKey);
        this.sstable = sstable;
        this.filter = filter;
        this.selectedColumns = selectedColumns;
        this.isForThrift = isForThrift;
        this.nowInSec = nowInSec;
        this.applyThriftTransformation = applyThriftTransformation;
        this.lowerBound = null;
        this.firstItemRetrieved = false;
    }

    public Unfiltered lowerBound()
    {
        if (lowerBound != null)
            return makeBound(lowerBound);

        // The partition index lower bound is more accurate than the sstable metadata lower bound but it is only
        // present if the iterator has already been initialized, which we only do when there are tombstones since in
        // this case we cannot use the sstable metadata clustering values
        ClusteringBound ret = getPartitionIndexLowerBound();
        return ret != null ? makeBound(ret) : makeBound(getMetadataLowerBound());
    }

    private Unfiltered makeBound(ClusteringBound bound)
    {
        if (bound == null)
            return null;

        if (lowerBound != bound)
            lowerBound = bound;

        return new RangeTombstoneBoundMarker(lowerBound, DeletionTime.LIVE);
    }

    @Override
    protected UnfilteredRowIterator initializeIterator()
    {
        sstable.incrementReadCount();

        @SuppressWarnings("resource") // 'iter' is added to iterators which is closed on exception, or through the closing of the final merged iterator
        UnfilteredRowIterator iter = sstable.iterator(partitionKey(), filter.getSlices(metadata()), selectedColumns, filter.isReversed(), isForThrift);
        return isForThrift && applyThriftTransformation
               ? ThriftResultsMerger.maybeWrap(iter, nowInSec)
               : iter;
    }

    @Override
    protected Unfiltered computeNext()
    {
        Unfiltered ret = super.computeNext();
        if (firstItemRetrieved)
            return ret;

        // Check that the lower bound is not bigger than the first item retrieved
        firstItemRetrieved = true;
        if (lowerBound != null && ret != null)
            assert comparator().compare(lowerBound, ret.clustering()) <= 0
                : String.format("Lower bound [%s ]is bigger than first returned value [%s] for sstable %s",
                                lowerBound.toString(sstable.metadata),
                                ret.toString(sstable.metadata),
                                sstable.getFilename());

        return ret;
    }

    private Comparator<Clusterable> comparator()
    {
        return filter.isReversed() ? sstable.metadata.comparator.reversed() : sstable.metadata.comparator;
    }

    @Override
    public CFMetaData metadata()
    {
        return sstable.metadata;
    }

    @Override
    public boolean isReverseOrder()
    {
        return filter.isReversed();
    }

    @Override
    public PartitionColumns columns()
    {
        return selectedColumns.fetchedColumns();
    }

    @Override
    public EncodingStats stats()
    {
        return sstable.stats();
    }

    @Override
    public DeletionTime partitionLevelDeletion()
    {
        if (!sstable.hasTombstones())
            return DeletionTime.LIVE;

        return super.partitionLevelDeletion();
    }

    @Override
    public Row staticRow()
    {
        if (columns().statics.isEmpty())
            return Rows.EMPTY_STATIC_ROW;

        return super.staticRow();
    }

    /**
     * @return the lower bound stored on the index entry for this partition, if available.
     */
    private ClusteringBound getPartitionIndexLowerBound()
    {
        // NOTE: CASSANDRA-11206 removed the lookup against the key-cache as the IndexInfo objects are no longer
        // in memory for not heap backed IndexInfo objects (so, these are on disk).
        // CASSANDRA-11369 is there to fix this afterwards.

        // Creating the iterator ensures that rowIndexEntry is loaded if available (partitions bigger than
        // DatabaseDescriptor.column_index_size_in_kb)
        if (!canUseMetadataLowerBound())
            maybeInit();

        RowIndexEntry rowIndexEntry = sstable.getCachedPosition(partitionKey(), false);
        if (rowIndexEntry == null || !rowIndexEntry.indexOnHeap())
            return null;

        try (RowIndexEntry.IndexInfoRetriever onHeapRetriever = rowIndexEntry.openWithIndex(null))
        {
            IndexInfo column = onHeapRetriever.columnsIndex(filter.isReversed() ? rowIndexEntry.columnsIndexCount() - 1 : 0);
            ClusteringPrefix lowerBoundPrefix = filter.isReversed() ? column.lastName : column.firstName;
            assert lowerBoundPrefix.getRawValues().length <= sstable.metadata.comparator.size() :
            String.format("Unexpected number of clustering values %d, expected %d or fewer for %s",
                          lowerBoundPrefix.getRawValues().length,
                          sstable.metadata.comparator.size(),
                          sstable.getFilename());
            return ClusteringBound.inclusiveOpen(filter.isReversed(), lowerBoundPrefix.getRawValues());
        }
        catch (IOException e)
        {
            throw new RuntimeException("should never occur", e);
        }
    }

    /**
     * @return true if we can use the clustering values in the stats of the sstable:
     * - we need the latest stats file format (or else the clustering values create clusterings with the wrong size)
     * - we cannot create tombstone bounds from these values only and so we rule out sstables with tombstones
     */
    private boolean canUseMetadataLowerBound()
    {
        return !sstable.hasTombstones() && sstable.descriptor.version.hasNewStatsFile();
    }

    /**
     * @return a global lower bound made from the clustering values stored in the sstable metadata, note that
     * this currently does not correctly compare tombstone bounds, especially ranges.
     */
    private ClusteringBound getMetadataLowerBound()
    {
        if (!canUseMetadataLowerBound())
            return null;

        final StatsMetadata m = sstable.getSSTableMetadata();
        List<ByteBuffer> vals = filter.isReversed() ? m.maxClusteringValues : m.minClusteringValues;
        assert vals.size() <= sstable.metadata.comparator.size() :
        String.format("Unexpected number of clustering values %d, expected %d or fewer for %s",
                      vals.size(),
                      sstable.metadata.comparator.size(),
                      sstable.getFilename());
        return  ClusteringBound.inclusiveOpen(filter.isReversed(), vals.toArray(new ByteBuffer[vals.size()]));
    }
}