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