001 /* 002 * $Id: ElemFactory.java 3193 2010-06-26 20:10:37Z kredel $ 003 */ 004 005 package edu.jas.structure; 006 007 import java.math.BigInteger; 008 import java.io.Reader; 009 import java.io.Serializable; 010 import java.util.Random; 011 import java.util.List; 012 013 /** 014 * Element factory interface. 015 * Defines embedding of integers, parsing and random element construction. 016 * @author Heinz Kredel 017 */ 018 019 public interface ElemFactory<C extends Element<C>> extends Serializable { 020 021 022 /** 023 * Get a list of the generating elements. 024 * @return list of generators for the algebraic structure. 025 */ 026 public List<C> generators(); 027 028 029 /** 030 * Is this structure finite or infinite. 031 * @return true if this structure is finite, else false. 032 */ 033 public boolean isFinite(); 034 035 036 /** 037 * Get the Element for a. 038 * @param a long 039 * @return element corresponding to a. 040 */ 041 public C fromInteger(long a); 042 043 044 /** 045 * Get the Element for a. 046 * @param a java.math.BigInteger. 047 * @return element corresponding to a. 048 */ 049 public C fromInteger(BigInteger a); 050 051 052 /** 053 * Generate a random Element with size less equal to n. 054 * @param n 055 * @return a random element. 056 */ 057 public C random(int n); 058 059 060 /** 061 * Generate a random Element with size less equal to n. 062 * @param n 063 * @param random is a source for random bits. 064 * @return a random element. 065 */ 066 public C random(int n, Random random); 067 068 069 /** 070 * Create a copy of Element c. 071 * @param c 072 * @return a copy of c. 073 */ 074 public C copy(C c); 075 076 077 /** 078 * Parse from String. 079 * @param s String. 080 * @return a Element corresponding to s. 081 */ 082 public C parse(String s); 083 084 085 /** 086 * Parse from Reader. 087 * @param r Reader. 088 * @return the next Element found on r. 089 */ 090 public C parse(Reader r); 091 092 093 /** Get a scripting compatible string representation. 094 * @return script compatible representation for this ElemFactory. 095 */ 096 public String toScript(); 097 098 }