You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/04/26 11:15:45 UTC
[Lucene.Net] svn commit: r1096700 - in
/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core: ./ Index/
Author: digy
Date: Tue Apr 26 09:15:45 2011
New Revision: 1096700
URL: http://svn.apache.org/viewvc?rev=1096700&view=rev
Log:
[LUCENENET-412]
Modified:
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CompoundFileReader.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DirectoryReader.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocConsumer.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldProcessor.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexFileNameFilter.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/LogMergePolicy.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ReadOnlyDirectoryReader.cs
incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CompoundFileReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CompoundFileReader.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CompoundFileReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/CompoundFileReader.cs Tue Apr 26 09:15:45 2011
@@ -52,7 +52,7 @@ namespace Lucene.Net.Index
private System.String fileName;
private IndexInput stream;
- private System.Collections.Hashtable entries = new System.Collections.Hashtable();
+ private SupportClass.Dictionary<string, FileEntry> entries = new SupportClass.Dictionary<string, FileEntry>();
public CompoundFileReader(Directory dir, System.String name):this(dir, name, BufferedIndexInput.BUFFER_SIZE)
@@ -160,7 +160,7 @@ namespace Lucene.Net.Index
if (stream == null)
throw new System.IO.IOException("Stream closed");
- FileEntry entry = (FileEntry) entries[id];
+ FileEntry entry = entries[id];
if (entry == null)
throw new System.IO.IOException("No sub-file with id " + id + " found");
@@ -214,7 +214,7 @@ namespace Lucene.Net.Index
/// <throws> IOException if the file does not exist </throws>
public override long FileLength(System.String name)
{
- FileEntry e = (FileEntry) entries[name];
+ FileEntry e = entries[name];
if (e == null)
throw new System.IO.IOException("File " + name + " does not exist");
return e.length;
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DirectoryReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DirectoryReader.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DirectoryReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DirectoryReader.cs Tue Apr 26 09:15:45 2011
@@ -102,7 +102,7 @@ namespace Lucene.Net.Index
private SegmentReader[] subReaders;
private int[] starts; // 1st docno for each segment
- private System.Collections.IDictionary normsCache = new System.Collections.Hashtable();
+ private IDictionary<string, byte[]> normsCache = new SupportClass.Dictionary<string, byte[]>();
private int maxDoc = 0;
private int numDocs = - 1;
private bool hasDeletions = false;
@@ -239,7 +239,7 @@ namespace Lucene.Net.Index
}
/// <summary>This constructor is only used for {@link #Reopen()} </summary>
- internal DirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts, System.Collections.IDictionary oldNormsCache, bool readOnly, bool doClone, int termInfosIndexDivisor)
+ internal DirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts, IDictionary<string,byte[]> oldNormsCache, bool readOnly, bool doClone, int termInfosIndexDivisor)
{
this.directory = directory;
this.readOnly = readOnly;
@@ -254,14 +254,14 @@ namespace Lucene.Net.Index
// we put the old SegmentReaders in a map, that allows us
// to lookup a reader using its segment name
- System.Collections.IDictionary segmentReaders = new System.Collections.Hashtable();
+ IDictionary<string,int?> segmentReaders = new SupportClass.Dictionary<string,int?>();
if (oldReaders != null)
{
// create a Map SegmentName->SegmentReader
for (int i = 0; i < oldReaders.Length; i++)
{
- segmentReaders[oldReaders[i].GetSegmentName()] = (System.Int32) i;
+ segmentReaders[oldReaders[i].GetSegmentName()] = i;
}
}
@@ -274,7 +274,7 @@ namespace Lucene.Net.Index
for (int i = infos.Count - 1; i >= 0; i--)
{
// find SegmentReader for this segment
- int? oldReaderIndex = (int?)segmentReaders[infos.Info(i).name];
+ int? oldReaderIndex = segmentReaders[infos.Info(i).name];
if (oldReaderIndex.HasValue == false)
{
// this is a new segment, no old SegmentReader can be reused
@@ -356,23 +356,21 @@ namespace Lucene.Net.Index
// try to copy unchanged norms from the old normsCache to the new one
if (oldNormsCache != null)
{
- System.Collections.IEnumerator it = new System.Collections.Hashtable(oldNormsCache).GetEnumerator();
- while (it.MoveNext())
- {
- System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) it.Current;
- System.String field = (System.String) entry.Key;
+ foreach (KeyValuePair<string, byte[]> entry in oldNormsCache)
+ {
+ System.String field = entry.Key;
if (!HasNorms(field))
{
continue;
}
- byte[] oldBytes = (byte[]) entry.Value;
+ byte[] oldBytes = entry.Value;
byte[] bytes = new byte[MaxDoc()];
for (int i = 0; i < subReaders.Length; i++)
{
- int? oldReaderIndex = (int?)segmentReaders[subReaders[i].GetSegmentName()];
+ int? oldReaderIndex = segmentReaders[subReaders[i].GetSegmentName()];
// this SegmentReader was not re-opened, we can copy all of its norms
if (oldReaderIndex.HasValue &&
@@ -818,7 +816,7 @@ namespace Lucene.Net.Index
protected internal override void DoSetNorm(int n, System.String field, byte value_Renamed)
{
- lock (normsCache.SyncRoot)
+ lock (normsCache)
{
normsCache.Remove(field); // clear cache
}
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocConsumer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocConsumer.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocConsumer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocConsumer.cs Tue Apr 26 09:15:45 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
namespace Lucene.Net.Index
{
@@ -23,7 +24,7 @@ namespace Lucene.Net.Index
abstract class DocConsumer
{
public abstract DocConsumerPerThread AddThread(DocumentsWriterThreadState perThread);
- public abstract void Flush(System.Collections.ICollection threads, SegmentWriteState state);
+ public abstract void Flush(IDictionary<DocConsumerPerThread, DocConsumerPerThread> threads, SegmentWriteState state);
public abstract void CloseDocStore(SegmentWriteState state);
public abstract void Abort();
public abstract bool FreeRAM();
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldProcessor.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldProcessor.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldProcessor.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocFieldProcessor.cs Tue Apr 26 09:15:45 2011
@@ -49,18 +49,16 @@ namespace Lucene.Net.Index
consumer.CloseDocStore(state);
fieldsWriter.CloseDocStore(state);
}
-
- public override void Flush(System.Collections.ICollection threads, SegmentWriteState state)
+
+ public override void Flush(IDictionary<DocConsumerPerThread, DocConsumerPerThread> threads, SegmentWriteState state)
{
SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>> childThreadsAndFields = new SupportClass.Dictionary<DocFieldConsumerPerThread, IList<DocFieldConsumerPerField>>();
- System.Collections.IEnumerator it = threads.GetEnumerator();
- while (it.MoveNext())
- {
- DocFieldProcessorPerThread perThread = (DocFieldProcessorPerThread) ((System.Collections.DictionaryEntry) it.Current).Key;
- childThreadsAndFields[perThread.consumer] = perThread.Fields();
- perThread.TrimFields(state);
- }
+ foreach (DocFieldProcessorPerThread perThread in threads.Keys)
+ {
+ childThreadsAndFields[perThread.consumer] = perThread.Fields();
+ perThread.TrimFields(state);
+ }
fieldsWriter.Flush(state);
consumer.Flush(childThreadsAndFields, state);
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs Tue Apr 26 09:15:45 2011
@@ -166,7 +166,7 @@ namespace Lucene.Net.Index
// than this they share ThreadStates
private const int MAX_THREAD_STATE = 5;
private DocumentsWriterThreadState[] threadStates = new DocumentsWriterThreadState[0];
- private System.Collections.Hashtable threadBindings = new System.Collections.Hashtable();
+ private SupportClass.Dictionary<SupportClass.ThreadClass, DocumentsWriterThreadState> threadBindings = new SupportClass.Dictionary<SupportClass.ThreadClass, DocumentsWriterThreadState>();
private int pauseThreads; // Non-zero when we need all threads to
// pause (eg to flush)
@@ -798,7 +798,7 @@ namespace Lucene.Net.Index
flushState.numDocsInStore = 0;
}
- System.Collections.Hashtable threads = new System.Collections.Hashtable();
+ IDictionary<DocConsumerPerThread,DocConsumerPerThread> threads = new SupportClass.Dictionary<DocConsumerPerThread,DocConsumerPerThread>();
for (int i = 0; i < threadStates.Length; i++)
threads[threadStates[i].consumer] = threadStates[i].consumer;
consumer.Flush(threads, flushState);
@@ -927,7 +927,7 @@ namespace Lucene.Net.Index
// First, find a thread state. If this thread already
// has affinity to a specific ThreadState, use that one
// again.
- DocumentsWriterThreadState state = (DocumentsWriterThreadState) threadBindings[SupportClass.ThreadClass.Current()];
+ DocumentsWriterThreadState state = threadBindings[SupportClass.ThreadClass.Current()];
if (state == null)
{
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexFileNameFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexFileNameFilter.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexFileNameFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexFileNameFilter.cs Tue Apr 26 09:15:45 2011
@@ -29,21 +29,21 @@ namespace Lucene.Net.Index
{
private static IndexFileNameFilter singleton = new IndexFileNameFilter();
- private System.Collections.Hashtable extensions;
- private System.Collections.Hashtable extensionsInCFS;
+ private SupportClass.Set<string> extensions;
+ private SupportClass.Set<string> extensionsInCFS;
// Prevent instantiation.
private IndexFileNameFilter()
{
- extensions = new System.Collections.Hashtable();
+ extensions = new SupportClass.Set<string>();
for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS.Length; i++)
{
- extensions.Add(IndexFileNames.INDEX_EXTENSIONS[i], IndexFileNames.INDEX_EXTENSIONS[i]);
+ extensions.Add(IndexFileNames.INDEX_EXTENSIONS[i]);
}
- extensionsInCFS = new System.Collections.Hashtable();
+ extensionsInCFS = new SupportClass.Set<string>();
for (int i = 0; i < IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE.Length; i++)
{
- extensionsInCFS.Add(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i], IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]);
+ extensionsInCFS.Add(IndexFileNames.INDEX_EXTENSIONS_IN_COMPOUND_FILE[i]);
}
}
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs Tue Apr 26 09:15:45 2011
@@ -294,7 +294,7 @@ namespace Lucene.Net.Index
private long lastCommitChangeCount; // last changeCount that was committed
private SegmentInfos rollbackSegmentInfos; // segmentInfos we will fallback to if the commit fails
- private System.Collections.Hashtable rollbackSegments;
+ private SupportClass.Dictionary<SegmentInfo, int> rollbackSegments;
internal volatile SegmentInfos pendingCommit; // set when a commit is pending (after prepareCommit() & before commit())
internal volatile uint pendingCommitChangeCount;
@@ -310,7 +310,7 @@ namespace Lucene.Net.Index
private DocumentsWriter docWriter;
private IndexFileDeleter deleter;
- private System.Collections.Hashtable segmentsToOptimize = new System.Collections.Hashtable(); // used by optimize to note those needing optimization
+ private SupportClass.Set<SegmentInfo> segmentsToOptimize = new SupportClass.Set<SegmentInfo>(); // used by optimize to note those needing optimization
private Lock writeLock;
@@ -1944,10 +1944,10 @@ namespace Lucene.Net.Index
{
rollbackSegmentInfos = (SegmentInfos) infos.Clone();
System.Diagnostics.Debug.Assert(!rollbackSegmentInfos.HasExternalSegments(directory));
- rollbackSegments = new System.Collections.Hashtable();
+ rollbackSegments = new SupportClass.Dictionary<SegmentInfo, int>();
int size = rollbackSegmentInfos.Count;
for (int i = 0; i < size; i++)
- rollbackSegments[rollbackSegmentInfos.Info(i)] = (System.Int32) i;
+ rollbackSegments[rollbackSegmentInfos.Info(i)] = i;
}
}
@@ -3316,11 +3316,11 @@ namespace Lucene.Net.Index
lock (this)
{
ResetMergeExceptions();
- segmentsToOptimize = new System.Collections.Hashtable();
+ segmentsToOptimize = new SupportClass.Set<SegmentInfo>();
optimizeMaxNumSegments = maxNumSegments;
int numSegments = segmentInfos.Count;
for (int i = 0; i < numSegments; i++)
- SupportClass.CollectionsHelper.AddIfNotContains(segmentsToOptimize, segmentInfos.Info(i));
+ segmentsToOptimize.Add(segmentInfos.Info(i));
// Now mark all pending & running merges as optimize
// merge:
@@ -5389,7 +5389,7 @@ namespace Lucene.Net.Index
if (merge.optimize)
{
// cascade the optimize:
- segmentsToOptimize[merge.info] = merge.info;
+ segmentsToOptimize.Add(merge.info);
}
return true;
}
@@ -5805,7 +5805,7 @@ namespace Lucene.Net.Index
bool exist = rollbackSegments.ContainsKey(info);
if (exist)
{
- int loc = (System.Int32) rollbackSegments[info];
+ int loc = rollbackSegments[info];
SegmentInfo oldInfo = rollbackSegmentInfos.Info(loc);
if (oldInfo.GetUseCompoundFile() != info.GetUseCompoundFile())
freeableBytes += info.SizeInBytes();
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/LogMergePolicy.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/LogMergePolicy.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/LogMergePolicy.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/LogMergePolicy.cs Tue Apr 26 09:15:45 2011
@@ -236,8 +236,8 @@ namespace Lucene.Net.Index
return byteSize;
}
}
-
- private bool IsOptimized(SegmentInfos infos, int maxNumSegments, System.Collections.Hashtable segmentsToOptimize)
+
+ private bool IsOptimized(SegmentInfos infos, int maxNumSegments, SupportClass.Set<SegmentInfo> segmentsToOptimize)
{
int numSegments = infos.Count;
int numToOptimize = 0;
@@ -275,7 +275,7 @@ namespace Lucene.Net.Index
/// (mergeFactor at a time) so the {@link MergeScheduler}
/// in use may make use of concurrency.
/// </summary>
- public override MergeSpecification FindMergesForOptimize(SegmentInfos infos, int maxNumSegments, System.Collections.Hashtable segmentsToOptimize)
+ public override MergeSpecification FindMergesForOptimize(SegmentInfos infos, int maxNumSegments, SupportClass.Set<SegmentInfo> segmentsToOptimize)
{
MergeSpecification spec;
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs Tue Apr 26 09:15:45 2011
@@ -283,7 +283,7 @@ namespace Lucene.Net.Index
/// <param name="segmentsToOptimize">contains the specific SegmentInfo instances that must be merged
/// away. This may be a subset of all SegmentInfos.
/// </param>
- public abstract MergeSpecification FindMergesForOptimize(SegmentInfos segmentInfos, int maxSegmentCount, System.Collections.Hashtable segmentsToOptimize);
+ public abstract MergeSpecification FindMergesForOptimize(SegmentInfos segmentInfos, int maxSegmentCount, SupportClass.Set<SegmentInfo> segmentsToOptimize);
/// <summary> Determine what set of merge operations is necessary in order to expunge all
/// deletes from the index.
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ReadOnlyDirectoryReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ReadOnlyDirectoryReader.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ReadOnlyDirectoryReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ReadOnlyDirectoryReader.cs Tue Apr 26 09:15:45 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using Directory = Lucene.Net.Store.Directory;
@@ -28,7 +29,7 @@ namespace Lucene.Net.Index
{
}
- internal ReadOnlyDirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts, System.Collections.IDictionary oldNormsCache, bool doClone, int termInfosIndexDivisor):base(directory, infos, oldReaders, oldStarts, oldNormsCache, true, doClone, termInfosIndexDivisor)
+ internal ReadOnlyDirectoryReader(Directory directory, SegmentInfos infos, SegmentReader[] oldReaders, int[] oldStarts, IDictionary<string,byte[]> oldNormsCache, bool doClone, int termInfosIndexDivisor):base(directory, infos, oldReaders, oldStarts, oldNormsCache, true, doClone, termInfosIndexDivisor)
{
}
Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs?rev=1096700&r1=1096699&r2=1096700&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs Tue Apr 26 09:15:45 2011
@@ -1409,7 +1409,7 @@ public class SupportClass
public class Dictionary<K, V> : System.Collections.Generic.IDictionary<K, V>
{
System.Collections.Generic.IDictionary<K, V> _Dict = null;
-
+
public Dictionary()
{
_Dict = new System.Collections.Generic.Dictionary<K, V>();
@@ -1435,8 +1435,6 @@ public class SupportClass
_Dict = new System.Collections.Generic.Dictionary<K, V>(dict);
}
-
-
public void Add(K key, V value)
{
_Dict.Add(key, value);
@@ -1558,6 +1556,17 @@ public class SupportClass
base.Add(item);
}
}
+
+ public new bool Contains(T item)
+ {
+ return _Set.Contains(item);
+ }
+
+ public new void Clear()
+ {
+ _Set.Clear();
+ base.Clear();
+ }
}
public class Cryptography