diff --git a/.gitignore b/.gitignore index 471b608..5ec64fb 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,8 @@ /Semester 2/Exams/Ajax3-Tags-Testing/target/ /Semester 2/Exams/Ajax4Listener/target/ /Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/target/ +/Semester 3/Assignments/Ajz5/target/ +/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/nbproject/private/ +/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/target/ +/Semester 3/Assignments/mavenproject1/target/ +/Semester 3/Assignments/Templates01_CalebFontenot/target/ diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/nb-configuration.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/nb-configuration.xml new file mode 100644 index 0000000..987f0a3 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/nb-configuration.xml @@ -0,0 +1,19 @@ + + + + + + 10-web + gfv700ee10 + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/pom.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/pom.xml new file mode 100644 index 0000000..fe668f2 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + edu.slcc.asdv.caleb + Ajax6_getters_setters_CalebFontenot + 1.0-SNAPSHOT + war + Ajax6_getters_setters_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + org.primefaces + primefaces + 13.0.4 + jakarta + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/ListASDV.java b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/ListASDV.java new file mode 100644 index 0000000..2e2cd3b --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/ListASDV.java @@ -0,0 +1,1700 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package beans; + +/** + * + * @author caleb + */ + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map.Entry; +import java.util.NoSuchElementException; +import java.util.Queue; +import java.util.function.Consumer; + +public class ListASDV + implements Serializable, + Cloneable, + Iterable, + Collection, Deque, List, Queue +{ + + public Node head; + public Node tail; + BigInteger size; + + public class Node + { + + public E e; + public Node l; + public Node r; + } + public BigInteger sizeBigInteger() + { + return size; + } + /** + * Constructs an empty list. + */ + public ListASDV() + { + size = new BigInteger("0"); + } + + /** + * Constructs a list containing the elements of the specified collection, in + * the order they are returned by the collection's iterator. + * + * @param c - the collection whose elements are to be placed into this list + * @throws NullPointerException - if the specified collection is null + */ + public ListASDV(Collection c) + { + if (c == null) + { + throw new NullPointerException("Null parameter " + c); + } + this.addAll(c); + size.add(new BigInteger( Integer.toString(c.size()))); + } + + /** + * @return Iteraror with the implementation of: hasNext, next + * forEachRemaining + */ + @Override + public Iterator iterator() + { + Iterator it = new Iterator() + { + Node trailNext = head; + @Override public boolean hasNext() + { + if (trailNext == null) + { + trailNext = head; + return false; + } + return true; + } + @Override public E next() + { + Node temp = trailNext; + trailNext = trailNext.r; + return temp.e; + } + /** + * Performs the given action for each remaining element until all + * elements have been processed or the action throws an exception. + * + * @param action has method accept(T t) which performs this + * operation on the given argument. + */ + @Override public void forEachRemaining(Consumer action) + { + //Node temp = trailNext; + //while (temp != null){action.accept(temp.e);temp = temp.r;} + while (hasNext()) action.accept( next() ); + } + }; + return it; + } + + /** + * Inserts all of the elements in the specified collection into this list, + * starting at the specified position. Shifts the element currently at that + * position (if any) and any subsequent elements to the right (increases + * their indices). The new elements will appear in the list in the order + * that they are returned by the specified collection's iterator. + * + * @param index - index at which to insert the first element from the + * specified collection + * @param c - collection containing elements to be added to this list + * @return true if this list changed as a result of the call + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LESS 0 || index GREATER size()) + * @throws NullPointerException - if the specified collection is null + */ + @Override + public boolean addAll(int index, Collection c) + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("IndexOutOfBoundsException, index: " + index); + } + if (c == null) + { + throw new NullPointerException("Null parameter " + c); + } + Node temp = tail; + for (E e : c) + { + add(index++, e); + } + size.add(new BigInteger( Integer.toString(c.size()))); + + return temp != tail; + } + + /** + * Returns the element at the specified position in this list. + * + * @param index - index of the element to return + * @return the element at the specified position in this list + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LT 0 || index GE size()) + */ + @Override + public E get(int index) + { + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + return temp.e; + } + + /** + * Replaces the element at the specified position in this list with the + * specified element (optional operation). + * + * @param index - index of the element to replace + * @param element + * @return element - the element previously at the specified position + * @throws ClassCastException - if the class of the specified element + * prevents it from being added to this list + * @throws NullPointerException - if the specified element is null and this + * list does not permit null elements + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this list + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index GE size()) + */ + @Override + public E set(int index, E element) + { + + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + if (element == null) + { + throw new NullPointerException("Null parameter " + element); + } + + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + E e = temp.e; + temp.e = element; + return e; + } + + /** + * Inserts the specified element at the specified position in this list. + * Shifts the element currently at that position (if any) and any subsequent + * elements to the right (adds one to their indices). + * + * @param index at which the specified element is to be inserted + * @param element - element to be appended to this list + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index G size()) + */ + @Override + public void add(int index, E element) + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + if (element == null) + { + throw new NullPointerException("Null parameter " + element); + } + Node newNode = new Node(); + newNode.e = element; + if (head == null) + { + tail = head = newNode; + } + else + { + if (index == 0)//add in the front + { + newNode.r = head; + head.l = newNode; + head = newNode; + } + else if (index == size())//add in the end + { + newNode.l = tail; + tail.r = newNode; + tail = newNode; + } + else //add in the middle + { + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + + newNode.r = temp; + newNode.l = temp.l; + temp.l.r = newNode; + temp.l = newNode; + + } + } + size.add(new BigInteger( "1")); + + } + + /** + * Removes the element at the specified position in this list. Shifts any + * subsequent elements to the left (subtracts one from their indices). + * Returns the element that was removed from the list. + * + * @param index the index of the element to be removed + * @return the element previously at the specified position, null if empty + * list + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LESS 0 or index GE size() + */ + @Override + public E remove(int index) + { + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Index Out of bounds exception : " + index); + } + if (size() == 0) + { + return null; + } + size.subtract(new BigInteger( "1")); + if (size() == 1 && index == 0)//special case just having 1 node + { + Node temp = head; + head = tail = null; + return temp.e; + } + else if (index == 0)//remove the first node + { + Node temp = head; + head = head.r; + head.l = null; + return temp.e; + } + else if (index == size() - 1)//remove last node + { + Node temp = tail; + tail = tail.l; + tail.r = null; + return temp.e; + } + else //remove in the middle + { + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + + temp.l.r = temp.r; + temp.r.l = temp.l; + return temp.e; + } + } + + /** + * Returns the index of the first occurrence of the specified element in + * this list, or -1 if this list does not contain the element. More + * formally, returns the lowest index i such that (o==null ? get(i)==null : + * o.equals(get(i))), or -1 if there is no such index. + * + * + * @param o - element to search for + * @return the index of the first occurrence of the specified element in + * this list, or -1 if this list does not contain the element + * @throws ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + */ + @Override + public int indexOf(Object o) + { + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + E e = it.next(); + if (e.equals(o)) + { + return i; + } + i++; + } + return -1; + } + + /** + * Returns the index of the last occurrence of the specified element in this + * list, or -1 if this list does not contain the element. More formally, + * returns the highest index i such that (o==null ? get(i)==null : + * o.equals(get(i))), or -1 if there is no such index. + * + * + * + * @param o - element to search for + * @return the index of the last occurrence of the specified element in this + * list, or -1 if this list does not contain the element + * @throws:ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + * + */ + @Override + public int lastIndexOf(Object o) + { + Iterator it = this.descendingIterator(); + int index = size() - 1; + while (it.hasNext()) + { + if (it.next().equals(o)) + { + return index; + } + --index; + } + return -1; + } + + /** + * Returns a list-iterator of the elements in this list (in proper + * sequence), starting at the specified position in the list. Obeys the + * general contract of List.listIterator(int). implements : hasNext, next,, + * previous, hasPrevious, nextIndex, previousIndex + * + * @param index - index of the first element to be returned from the + * list-iterator (by a call to next) + * @return a ListIterator of the elements in this list (in proper sequence), + * starting at the specified position in the list + * + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index G size()) + */ + @Override + public ListIterator listIterator(int index) + { + ListIterator it = new ListIterator() + { + Node trailNext = trailNextInitialize(); + Node trailPrevious = trailNext.l; + + int nextIndex = index; + int previousIndex = nextIndex - 1; + + Node trailNextInitialize() + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("ListIterator index out of bounds: " + index); + } + trailNext = head; + for (int i = 0; i < index; ++i) + { + trailNext = trailNext.r; + } + return trailNext; + } + + /** + * Returns true if this list iterator has more elements when + * traversing the list in the forward direction. (In other words, + * returns true if next() would return an element rather than + * throwing an exception.) + * + * @return returns true if next() would return an element; + */ + @Override + public boolean hasNext() + { + if (trailNext == null) + { + trailNext = head; + trailPrevious = trailNext.l; + nextIndex = 0; + previousIndex = -1; + return false; + } + return true; + } + + /** + * Returns the next element in the list and advances the cursor + * position. This method may be called repeatedly to iterate through + * the list, or intermixed with calls to previous() to go back and + * forth. (Note that alternating calls to next and previous will + * return the same element repeatedly.) Specified by: next in + * interface IteratorLE E> + * NoSuchElementException - if the iteration has no next element + * + * @return the next element in the list + * @throws NoSuchElementException if the iteration has no next element + */ + @Override + public E next() + { + if ( trailNext == null ) + throw new NoSuchElementException( "mo next element exists"); + + Node temp = trailNext; + trailPrevious = trailNext; + trailNext = trailNext.r;//advance the trailNext to the next node + previousIndex = nextIndex;//advance previous index to next + nextIndex++;// advance the next index + + return temp.e; + } + + @Override + public boolean hasPrevious() + { + + if (trailPrevious == null) + { + trailNext = head; + trailPrevious = trailNext.l; + nextIndex = 0; + previousIndex = -1; + return false; + } + return true; + } + + @Override + public E previous() + { + if ( trailPrevious == null ) + throw new NoSuchElementException( "no next element exists"); + + Node temp = trailPrevious; + trailNext = trailPrevious; + trailPrevious = trailPrevious.l; + nextIndex = previousIndex; + previousIndex--; + return temp.e; + } + + @Override + public int nextIndex() + { + return nextIndex; + } + + @Override + public int previousIndex() + { + return previousIndex; + } + + @Override + public void remove() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void set(E e) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void add(E e) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }; + return it; + } + + /** + * One line of code here. Call listIterator(0) + * + * @return ListIterator + */ + @Override + public ListIterator listIterator() + { + return listIterator(0); + } + + /** + * Returns a view of the portion of this list between the specified + * fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex + * are equal, the returned list is empty.) The returned list is backed by + * this list, so non-structural changes in the returned list are reflected + * in this list, and vice-versa. The returned list supports all of the + * optional list operations supported by this list. + * + * + * @param fromIndex - low endpoint (inclusive) of the subList + * @param toIndex - high endpoint (exclusive) of the subList + * @return a view of the specified range within this list + * @throws Throws: IndexOutOfBoundsException - for an illegal endpoint index + * value (fromIndex L 0 || toIndex G size || fromIndex > toIndex) + */ + @Override + public List subList(int fromIndex, int toIndex) + { + if (fromIndex > toIndex || fromIndex < 0 || toIndex > size()) + { + throw new IndexOutOfBoundsException("Index out of Bounds exception " + fromIndex + " " + toIndex); + } + + E[] a = (E[]) new Object[0]; + a = toArray(a); + a = Arrays.copyOfRange(a, fromIndex, toIndex); + return Arrays.asList(a); + } + + @Override + public int size() + { + Node temp = head; + int count = 0; + while (temp != null) + { + count++; + temp = temp.r; + } + return count; + } + + /** + * Tests is the list is empty + * + * @return true if the list is empty, false otherwise. + */ + @Override + public boolean isEmpty() + { + return head == null; + } + + /** + * + * Returns true if this list contains the specified element. More formally, + * returns true if and only if this list contains at least one element e + * such that (o==null ? e==null : o.equals(e)). + * + * @param o - element whose presence in this list is to be tested + * @return true if this list contains the specified element + * @throws ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + */ + @Override + public boolean contains(Object o) + { + Iterator it = this.iterator(); + while (it.hasNext()) + { + if (it.next().equals(o)) + { + return true; + } + } + return false; + } + + /** + * Returns an array containing all of the elements in this list in proper + * sequence (from first to last element). + * + * The returned array will be "safe" in that no references to it are + * maintained by this list. (In other words, this method must allocate a new + * array even if this list is backed by an array). The caller is thus free + * to modify the returned array. + * + * @return an array containing all of the elements in this list in proper + * sequence + */ + @Override + public Object[] toArray() + { + Object[] ar = new Object[size()]; + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + ar[i++] = it.next(); + } + return ar; + } + + /** + * Returns an array containing all of the elements in this list in proper + * sequence (from first to last element); the runtime type of the returned + * array is that of the specified array. If the list fits in the specified + * array, it is returned therein. Otherwise, a new array is allocated with + * the runtime type of the specified array and the size of this list. If the + * list fits in the specified array with room to spare (i.e., the array has + * more elements than the list), the element in the array immediately + * following the end of the list is set to null. (This is useful in + * determining the length of the list only if the caller knows that the list + * does not contain any null elements.) + * + * Like the toArray() method, this method acts as bridge between array-based + * and collection-based APIs. Further, this method allows precise control + * over the runtime type of the output array, and may, under certain + * circumstances, be used to save allocation costs. + * + * Suppose x is a list known to contain only strings. The following code can + * be used to dump the list into a newly allocated array of String: String[] + * y = x.toArray(new String[0]); Note that toArray(new Object[0]) is + * identical in function to toArray(). + * + * Specified by: toArray in interface Collection Type Parameters: T - the + * runtime type of the array to contain the collection Parameters: a - the + * array into which the elements of this list are to be stored, if it is big + * enough; otherwise, a new array of the same runtime type is allocated for + * this purpose. Returns: an array containing the elements of this list + * Throws: ArrayStoreException - if the runtime type of the specified array + * is not a supertype of the runtime type of every element in this list + * NullPointerException - if the specified array is null + * + * @param - the runtime type of the array to contain the collection + * @param a - the array into which the elements of this list are to be + * stored, if it is big enough; otherwise, a new array of the same runtime + * type is allocated for this purpose. + * + * @return an array containing the elements of this list + * @throws ArrayStoreException - if the runtime type of the specified array + * is not a supertype of the runtime type of every element in this list + * @throws NullPointerException - if the specified array is null + */ + @Override + public T[] toArray(T[] a) + { + if (a == null) + { + throw new NullPointerException("Null pointer exception: parameter is null"); + } + + if (a.length >= this.size()) + { + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + T e = (T) it.next(); + a[i++] = e; + } + return a; + } + else + { + T[] ar = Arrays.copyOf(a, size()); + + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + T e = (T) it.next(); + ar[i++] = e; + } + return ar; + } + + } + + /** + * Appends the specified element to the end of this list. This method is + * equivalent to addLast(E). + * + * @param e element to be appended to this list + * @return true if this collection changed as a result of the call + */ + @Override + public boolean add(E e) + { + Node newNode = new Node(); + newNode.e = e; + if (head == null) + { + head = tail = newNode; + } + else + { + newNode.l = tail; + tail.r = newNode; + tail = newNode; + } + size.add(new BigInteger( "1")); + return true; + } + + /** + * Removes a single instance of the specified element from this collection, + * if it is present (optional operation). More formally, removes an element + * e such that (o==null ? e==null : o.equals(e)), if this collection + * contains one or more such elements. + * + * + * @param o - element to be removed from this collection, if present + * @return true if this collection changed as a result of the call. + * @throws ClassCastException - if the type of the specified element is + * incompatible with this collection (optional) + * @throws NullPointerException - if the specified element is null and this + * collection does not permit null elements (optional) + */ + @Override + public boolean remove(Object o) + { + if (o == null) + { + throw new NullPointerException("Null Pointer exception, cant pass null arguments"); + } + Iterator it = this.iterator(); + int pos = 0; + while (it.hasNext()) + { + if (it.next().equals(o)) + { + remove(pos); + return true; + } + pos++; + } + return false; + } + + /** + * Returns true if this collection contains all of the elements in the + * specified collection. + * + * @param c - collection to be checked for containment in this collection + * @return true if this collection contains all of the elements in the + * specified collection + * @throws ClassCastException - if the types of one or more elements in the + * specified collection are incompatible with this collection (optional) + * @throws NullPointerException - if the specified collection contains one + * or more null elements and this collection does not permit null elements + * (optional), or if the specified collection is null. + */ + @Override + public boolean containsAll(Collection c) + { + for (Object o : c) + { + if (contains(o) == false) + { + return false; + } + } + return true; + } + + /** + * Appends all of the elements in the specified collection to the end of + * this list, in the order that they are returned by the specified + * collection's iterator. The behavior of this operation is undefined if the + * specified collection is modified while the operation is in progress. + * (Note that this will occur if the specified collection is this list, and + * it's nonempty.) + * + * @param c - collection containing elements to be added to this list + * @return true if this list changed as a result of the call + * @throws NullPointerException - if the specified collection is null + */ + @Override + public boolean addAll(Collection c) + { + Node temp = tail; + for (E e : c) + { + add(e); + } + return temp != tail; + } + + /** + * Removes from this list all of its elements that are contained in the + * specified collection (optional operation). + * + * @param c - collection containing elements to be removed from this list + * @return true if this list changed as a result of the call + * @throws ClassCastException - if the class of an element of this list is + * incompatible with the specified collection (optional) + */ + @Override + public boolean removeAll(Collection c) + { + Node temp1 = tail; + Node temp2 = head; + for (Object o : c) + { + while (this.remove(o))//remove all same occurances + ; + } + + return temp1 != tail || temp2 != head; + } + + /** + * Retains only the elements in this list that are contained in the + * specified collection (optional operation). In other words, removes from + * this list all of its elements that are not contained in the specified + * collection. + * + * @param c - collection containing elements to be retained in this list + * @return true if this list changed as a result of the call + * @throws ClassCastException - if the class of an element of this list is + * incompatible with the specified collection (optional) + */ + @Override + public boolean retainAll(Collection c) + { + ListASDV cloner = (ListASDV) this.clone(); + cloner.removeAll(c);//cloner has elements to be deleted in the original list + Iterator it = cloner.iterator(); + while (it.hasNext()) + { + Object o = it.next(); + while (this.remove(o)); + } + return true; + } + + /** + * Clears the list of all elements. + */ + @Override + public void clear() + { + size = new BigInteger( "0"); + head = tail = null; + } + + /** + * Inserts the specified element at the beginning of this list. + * + * @param e - the element to add + */ + @Override + public void addFirst(E e) + { + this.add(0, e); + } + + /** + * Appends the specified element to the end of this list. This method is + * equivalent to add(E). + * + * @param e - the element to add + */ + @Override + public void addLast(E e) + { + this.add(size(), e); + } + + /** + * Inserts the specified element at the front of this deque unless it would + * violate capacity restrictions. When using a capacity-restricted deque, + * this method is generally preferable to the addFirst(E) method, which can + * fail to insert an element only by throwing an exception. + * + * Parameters: e - the element to add Returns: true if the element was added + * to this deque, else false Throws: ClassCastException - if the class of + * the specified element prevents it from being added to this deque + * NullPointerException - if the specified element is null and this deque + * does not permit null elements IllegalArgumentException - if some property + * of the specified element prevents it from being added to this deque + * + * @param e - the element to add + * @return true if the element was added to this deque, else false + * @throws ClassCastException if the class of the specified element prevents + * it from being added to this deque + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this deque + */ + @Override + public boolean offerFirst(E e) + { + addFirst(e); + return true; + } + + /** + * Inserts the specified element at the end of this deque unless it would + * violate capacity restrictions. When using a capacity-restricted deque, + * this method is generally preferable to the addLast(E) method, which can + * fail to insert an element only by throwing an exception. + * + * Parameters: e - the element to add Returns: true if the element was added + * to this deque, else false Throws: ClassCastException - if the class of + * the specified element prevents it from being added to this deque + * NullPointerException - if the specified element is null and this deque + * does not permit null elements IllegalArgumentException - if some property + * of the specified element prevents it from being added to this deque + * + * @param e - the element to add + * @return true if the element was added to this deque, else false + * @throws ClassCastException - if the class of the specified element + * prevents it from being added to this deque + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this deque * + */ + @Override + public boolean offerLast(E e) + { + addLast(e); + return true; + } + + /** + * E removeFirst() + * + * Retrieves and removes the first element of this deque. This method + * differs from pollFirst only in that it throws an exception if this deque + * is empty. + * + * @return the head of this deque + * @throws NoSuchElementException - if this deque is empty + */ + @Override + public E removeFirst() + { + if (this.isEmpty()) + { + throw new NoSuchElementException("list is empty"); + } + return this.remove(0); + } + + /** + * Retrieves and removes the last element of this deque. This method differs + * from pollLast only in that it throws an exception if this deque is empty. + * + * @return the tail of this deque + * @thows NoSuchElementException - if this deque is empty + */ + @Override + public E removeLast() + { + if (this.isEmpty()) + { + throw new NoSuchElementException("list is empty"); + } + return this.remove(size() - 1); + } + + /** + * Retrieves and removes the first element of this deque, or returns null if + * this deque is empty. + * + * @return the head of this deque, or null if this deque is empty + */ + @Override + public E pollFirst() + { + return isEmpty() ? null : this.remove(0); + } + + /** + * Retrieves and removes the last element of this deque, or returns null if + * this deque is empty. + * + * @return the tail of this deque, or null if this deque is empty + */ + @Override + public E pollLast() + { + return isEmpty() ? null : this.remove(size() - 1); + } + + /** + * Retrieves, but does not remove, the first element of this deque. This + * method differs from peekFirst only in that it throws an exception if this + * deque is empty. + * + * @return the head of this deque + * @throws NoSuchElementException - if this deque is empty + */ + @Override + public E getFirst() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty"); + } + + return head.e; + } + + /** + * Retrieves, but does not remove, the last element of this deque. This + * method differs from peekLast only in that it throws an exception if this + * deque is empty. + * + * @return the tail of this deque + * @throws Throws: NoSuchElementException - if this deque is empty + */ + @Override + public E getLast() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty"); + } + return tail.e; + } + + /** + * Retrieves, but does not remove, the first element of this deque, or + * returns null if this deque is empty. + * + * @return the head of this deque, or null if this deque is empty + * + */ + @Override + public E peekFirst() + { + return isEmpty() ? null : this.get(0); + } + + /** + * Retrieves, but does not remove, the last element of this deque, or + * returns null if this deque is empty. + * + * @return the tail of this deque, or null if this deque is empty + */ + @Override + public E peekLast() + { + return isEmpty() ? null : this.get(size() - 1); + } + + /** + * Removes the first occurrence of the specified element from this deque. If + * the deque does not contain the element, it is unchanged. More formally, + * removes the first element e such that (o==null ? e==null : o.equals(e)) + * (if such an element exists). Returns true if this deque contained the + * specified element (or equivalently, if this deque changed as a result of + * the call). + * + * @param o - element to be removed from this deque, if present + * @return true if an element was removed as a result of this call + * @throws ClassCastException - if the class of the specified element is + * incompatible with this deque + */ + @Override + public boolean removeFirstOccurrence(Object o) + { + return isEmpty() ? false : this.remove(o); + + } + + /** + * Removes the last occurrence of the specified element from this deque. If + * the deque does not contain the element, it is unchanged. More formally, + * removes the last element e such that (o==null ? e==null : o.equals(e)) + * (if such an element exists). Returns true if this deque contained the + * specified element (or equivalently, if this deque changed as a result of + * the call) + * + * @param o - element to be removed from this deque, if present + * @return true if an element was removed as a result of this call + * @throws ClassCastException - if the class of the specified element is + * incompatible with this deque (optional) + */ + @Override + public boolean removeLastOccurrence(Object o) + { + Node temp = tail; + int index = size() - 1; + while (temp != null) + { + if (this.get(index).equals(o)) + { + this.remove(index); + return true; + } + index--; + temp = temp.l; + } + return false; + } + + /** + * Inserts the specified element into this queue if it is possible to do so + * immediately without violating capacity restrictions. When using a + * capacity-restricted queue, this method is generally preferable to add(E), + * which can fail to insert an element only by throwing an exception. + * + * + * @param e - the element to add + * @return true if the element was added to this queue, else false + * @throws: ClassCastException - if the class of the specified element + * prevents it from being added to this queue + */ + @Override + public boolean offer(E e) + { + return this.offerLast(e); + } + + /** + * Retrieves and removes the head of this queue. This method differs from + * poll only in that it throws an exception if this queue is empty. + * + * @return the head of this queue + * @throws NoSuchElementException - if this queue is empty + * + */ + @Override + public E remove() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Retrieves and removes the head of this queue, or returns null if this + * queue is empty. + * + * @return the head of this queue, or null if this queue is empty + * + */ + @Override + public E poll() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Retrieves, but does not remove, the head of this queue. This method + * differs from peek only in that it throws an exception if this queue is + * empty. + * + * @return the head of this queue + * @throws: NoSuchElementException - if this queue is empty + * + */ + @Override + public E element() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.get(0); + } + + /** + * Retrieves, but does not remove, the head of this queue, or returns null + * if this queue is empty. + * + * @return the head of this queue, or null if this queue is empty + */ + @Override + public E peek() + { + return isEmpty() ? null : this.get(0); + } + + /** + * Pushes an element onto the stack represented by this list. In other + * words, inserts the element at the front of this list. + * + * This method is equivalent to addFirst(E). Specified by: push in interface + * Deque + * + * @param e - the element to push + */ + @Override + public void push(E e) + { + this.addFirst(e); + } + + /** + * Pops an element from the stack represented by this list. In other words, + * removes and returns the first element of this list. + * + * This method is equivalent to removeFirst(). Specified by: pop in + * interface Deque + * + * @return the element at the front of this list (which is the top of the + * stack represented by this list) + * @throws: NoSuchElementException - if this list is empty + */ + @Override + public E pop() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Description copied from interface: Deque Returns an iterator over the + * elements in this deque in reverse sequential order. The elements will be + * returned in order from last (tail) to first (head). + * + * Specified by: descendingIterator in interface Deque + * + * @return an iterator over the elements in this deque in reverse sequence + */ + @Override + public Iterator descendingIterator() + { + + Iterator it = new Iterator() + { + Node trailPrevious = tail; + + @Override + public boolean hasNext() + { + if (trailPrevious == null) + { + trailPrevious = tail; + return false; + } + return true; + } + + @Override + public E next() + { + Node temp = trailPrevious; + trailPrevious = trailPrevious.l; + return temp.e; + } + }; + return it; + } + + /** + * Returns a deep clone of the list. + * + * @return the cloned list + */ + @Override + public Object clone() + { + ListASDV listCloned = new ListASDV(); + Iterator it = this.iterator(); + while (it.hasNext()) + { + + listCloned.add((E) it.next()); + } + return listCloned; + } + + @Override + public String toString() + { + + String s = "ListASDV{ "; + Iterator it = iterator(); + while (it.hasNext()) + { + s += it.next() + " "; + } + s += '}'; + return s; + } + + public static void main(String[] args) + { + class ASDV_ENTRY implements Entry + { + T1 key; + T2 value; + public ASDV_ENTRY( T1 t1, T2 t2) + { + key = t1; + value = t2; + } + @Override + public T1 getKey() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T1 getValue() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T1 setValue(T1 value) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + + } + Entry e1 = new ASDV_ENTRY("john", 20); + + ListASDV listTest = new ListASDV(); + listTest.add(e1); + + + ListASDV list = new ListASDV(); + list.add(100); + list.addFirst(50); + list.add(1, 75); + list.addLast(200); + List collection = Arrays.asList(new Integer[] + { + 300, 400 + }); + list.addAll(collection); + try + { + list.addAll(8, collection); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + Iterator it = list.iterator(); + System.out.println("\ntest add methods ***************************************"); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + + System.out.println(""); + System.out.println("\nforEachRemaining(action) ***************************************"); + + Consumer action = new Consumer() + { + @Override + public void accept(Integer t) + { + System.out.print("*" + t + " "); + } + + }; + it = list.iterator(); + it.next(); + it.next(); + it.forEachRemaining(action); + System.out.println(""); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + System.out.println(""); + it.forEachRemaining(action); + + System.out.println(""); + System.out.println("indexOf ***************************************"); + System.out.println(list.indexOf(new A())); + System.out.println(list.indexOf(200)); + System.out.println(list.indexOf(800)); + + System.out.println("\nclone() ***************************************"); + ListASDV listCloned = (ListASDV) list.clone(); + list.clear(); + it = listCloned.iterator(); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + System.out.println("\nsize of original list after clear: " + list.size()); + list.addAll(0, listCloned); + System.out.println("\ntoString() ***************************************\n" + list); + + System.out.println("\ncontains ***************************************"); + System.out.println(list.contains(new A())); + System.out.println(list.contains(200)); + System.out.println(list.contains(800)); + + System.out.println("\ncontainsAll ***************************************"); + try + { + System.out.println(list.containsAll((Collection) new A())); + } + catch (ClassCastException e) + { + System.out.println(e.getMessage()); + } + System.out.println(list.containsAll(listCloned)); + System.out.println(list.containsAll(Arrays.asList(new Integer[] + { + 100, 300 + }))); + System.out.println(list.containsAll(Arrays.asList(new Integer[] + { + 10, 300 + }))); + + System.out.println("\ndiscendingIterator ***************************************"); + Iterator descIt = list.descendingIterator(); + while (descIt.hasNext()) + { + Object o = descIt.next(); + System.out.print(o + " "); + } + + System.out.println("\nelement ***************************************"); + System.out.println(list.element()); + System.out.println(list.element()); + listCloned.clear(); + try + { + listCloned.element(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\nget(int) ***************************************"); + System.out.println(list.get(0)); + System.out.println(list.get(list.size() - 1)); + try + { + list.get(list.size()); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\ngetFirst() ***************************************"); + System.out.println(list.getFirst()); + System.out.println(list.getFirst()); + try + { + listCloned.getFirst(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\n getLAst()***************************************"); + System.out.println(list.getLast()); + System.out.println(list.getLast()); + + try + { + listCloned.getLast(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\n isEmpty()***************************************"); + System.out.println(list.isEmpty()); + System.out.println(listCloned.isEmpty()); + + System.out.println("\n lastIndexOf***************************************"); + list.add(1, -888); + list.add(4, -888); + System.out.println(list); + System.out.println(list.lastIndexOf(-888)); + System.out.println(list.lastIndexOf(12)); + System.out.println(list.lastIndexOf(new A())); + + System.out.println("\nlistIterator( index=3) using next***************************************"); + System.out.println(list); + ListIterator itList = list.listIterator(3); + + while (itList.hasNext()) + { + Object o = itList.next(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\nlistIterator( index=3) using previous ***************************************"); + System.out.println(list); + itList = list.listIterator(3); + + while (itList.hasPrevious()) + { + Object o = itList.previous(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\nlistIterator with next ***************************************"); + System.out.println(list); + itList = list.listIterator(); + + while (itList.hasNext()) + { + Object o = itList.next(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\noffer methods ***************************************"); + list.offer(500); + list.offerLast(600); + list.offerFirst(33); + System.out.println(list); + + System.out.println("\npeek poll methods ***************************************"); + System.out.println(list.peek()); + System.out.println(list.peekFirst()); + System.out.println(list.peekLast()); + System.out.println(listCloned.peekLast()); + System.out.println(list.poll()); + System.out.println(list.pollFirst()); + System.out.println(list.pollLast()); + System.out.println(listCloned.pollFirst()); + + System.out.println("\npush pop methods ***************************************"); + System.out.println(list); + Integer o = list.pop(); + list.push(o); + System.out.println(list); + try + { + listCloned.pop(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\nremove methods ***************************************"); + System.out.println(list); + System.out.println(list.removeLastOccurrence(-888)); + System.out.println(list); + System.out.println(list.remove()); + System.out.println(list.removeFirst()); + System.out.println(list); + System.out.println(list.remove((Integer) 300)); + try + { + list.remove(null); + } + catch (NullPointerException e) + { + System.out.println(e.getMessage()); + } + try + { + list.remove(200); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + System.out.println(list); + + System.out.println("\nremoveAll( Collection c) ***************************************"); + list.add(0, -888); + list.add(2, -888); + list.add(-888); + listCloned = (ListASDV) list.clone(); + System.out.println(list); + List col = Arrays.asList(new Integer[] + { + -888, 200 + }); + list.removeAll(col); + System.out.println(list); + + System.out.println("\nretailAll( Collection c) ***************************************"); + list = (ListASDV) listCloned.clone(); + list.retainAll(col); + System.out.println(list); + + System.out.println("\nset ***************************************"); + list.set(0, 100); + System.out.println(list); + + System.out.println("\nsubList ***************************************"); + List subList = list.subList(1, 3); + System.out.println(subList); + try + { + list.subList(1, 5); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\ntoArray ***************************************"); + System.out.println(list); + System.out.println(Arrays.asList(list.toArray())); + + Integer[] ar = new Integer[list.size()]; + System.out.println("\ntoArray(T[] ) ***************************************"); + System.out.println(list); + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = new Integer[1]; + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = new Integer[list.size() + list.size()]; + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = null; + try + { + list.toArray(ar); + } + catch (NullPointerException e) + { + System.out.println(e.getMessage()); + } + + } + +} + +class A +{ +} diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/TestBean1.java b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/TestBean1.java new file mode 100644 index 0000000..9e1ca7e --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/beans/TestBean1.java @@ -0,0 +1,71 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template + */ +package beans; + +import jakarta.inject.Named; +import jakarta.enterprise.context.RequestScoped; +import jakarta.faces.event.AbortProcessingException; +import jakarta.faces.event.AjaxBehaviorEvent; +import jakarta.faces.view.ViewScoped; +import java.io.Serializable; +import java.util.Date; + +/** + * + * @author asdv5 + */ +@Named(value = "testBean1") +@ViewScoped +public class TestBean1 implements Serializable +{ + public TestBean1() + { + System.out.println(" -----------------------constructor TestBean1()------------------"); + } + private String x; + private String y; + + public String getX() + { + System.out.println(" getX() " + x); + return x; + } + + public void setX(String x) + { + this.x = x; + System.out.println(" setX() " + x); + this.x += " x " + x; + } + + public String gety() + { + System.out.println(" getY() " + y); + return y; + } + + public void setY(String y) + { + this.y = y; + System.out.println(" setY() " + y); + this.y += " y " + y; + } + + public void toUpperCase(AjaxBehaviorEvent event) + throws AbortProcessingException + { + System.out.println("-------- ajaxListener()-------"); + if (this.x != null) + { + System.out.println(" ajaxListener() IF x " + x); + this.x = this.x.toUpperCase(); + } + if (this.y != null) + { + System.out.println(" ajaxListener() IF y " + y); + this.y = this.y.toUpperCase(); + } + } +} diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/JakartaRestConfiguration.java b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..20efa22 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.caleb.ajax6_getters_setters_calebfontenot; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/resources/JakartaEE10Resource.java b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..2f508d9 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/ajax6_getters_setters_calebfontenot/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.caleb.ajax6_getters_setters_calebfontenot.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/resources/META-INF/persistence.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/beans.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/web.xml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/ajax-listener-send-form-buttons.xhtml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/ajax-listener-send-form-buttons.xhtml new file mode 100644 index 0000000..c70ebc8 --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/ajax-listener-send-form-buttons.xhtml @@ -0,0 +1,68 @@ + + + + + Facelet Title + + + + + + + + + Prime Ajax tag: PROCESSes id_x UPDATEs id_x only. Ajax Listener will not be called + when we use PROCESS in the tag + + + + + Prime Ajax tag: when you use listener, the listener is executed before the setters. + So, do not use PROCESS when you use listener. + If you use PROCESS the listener is not called. + + + + + + + + + JSF Ajax PROCESSes id_x UPDATEs id_x only. Ajax Listener will not be called + when we use EXECUTE in the tag + + + + + JSF Ajax tag: when you use listener, the listener is executed before the setters. + So, do not use EXECUTE when you use listener. + If you use EXECUTE the listener is not called. + + + + + + + + + + + + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/index.xhtml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/index.xhtml new file mode 100644 index 0000000..b2d0f8e --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/index.xhtml @@ -0,0 +1,18 @@ + + + + + Ajax 6 + + + + + + + + + + + + diff --git a/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/send-form-buttons.xhtml b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/send-form-buttons.xhtml new file mode 100644 index 0000000..3d80b1a --- /dev/null +++ b/Semester 3/Assignments/Ajax6_getters_setters_CalebFontenot/src/main/webapp/send-form-buttons.xhtml @@ -0,0 +1,37 @@ + + + + + Facelet Title + + + + + + + + + calls setters ONLY, it DOES NOT render form + + + calls setters then getters, it DOES RENDER form + + + calls setters then getters, it DOES RENDER form same as ajax="false" + + + + + + diff --git a/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/nb-configuration.xml b/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/nb-configuration.xml index 5e1a2de..f7b0362 100644 --- a/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/nb-configuration.xml +++ b/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/nb-configuration.xml @@ -16,5 +16,6 @@ Any value defined here will override the pom.xml file value but is only applicab 10-web gfv700ee10 Facelets + JDK_15__System_ diff --git a/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/src/main/java/beans/ListASDV.java b/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/src/main/java/beans/ListASDV.java new file mode 100644 index 0000000..2e2cd3b --- /dev/null +++ b/Semester 3/Assignments/AjaxPrimeFaces_CalebFontenot/src/main/java/beans/ListASDV.java @@ -0,0 +1,1700 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package beans; + +/** + * + * @author caleb + */ + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map.Entry; +import java.util.NoSuchElementException; +import java.util.Queue; +import java.util.function.Consumer; + +public class ListASDV + implements Serializable, + Cloneable, + Iterable, + Collection, Deque, List, Queue +{ + + public Node head; + public Node tail; + BigInteger size; + + public class Node + { + + public E e; + public Node l; + public Node r; + } + public BigInteger sizeBigInteger() + { + return size; + } + /** + * Constructs an empty list. + */ + public ListASDV() + { + size = new BigInteger("0"); + } + + /** + * Constructs a list containing the elements of the specified collection, in + * the order they are returned by the collection's iterator. + * + * @param c - the collection whose elements are to be placed into this list + * @throws NullPointerException - if the specified collection is null + */ + public ListASDV(Collection c) + { + if (c == null) + { + throw new NullPointerException("Null parameter " + c); + } + this.addAll(c); + size.add(new BigInteger( Integer.toString(c.size()))); + } + + /** + * @return Iteraror with the implementation of: hasNext, next + * forEachRemaining + */ + @Override + public Iterator iterator() + { + Iterator it = new Iterator() + { + Node trailNext = head; + @Override public boolean hasNext() + { + if (trailNext == null) + { + trailNext = head; + return false; + } + return true; + } + @Override public E next() + { + Node temp = trailNext; + trailNext = trailNext.r; + return temp.e; + } + /** + * Performs the given action for each remaining element until all + * elements have been processed or the action throws an exception. + * + * @param action has method accept(T t) which performs this + * operation on the given argument. + */ + @Override public void forEachRemaining(Consumer action) + { + //Node temp = trailNext; + //while (temp != null){action.accept(temp.e);temp = temp.r;} + while (hasNext()) action.accept( next() ); + } + }; + return it; + } + + /** + * Inserts all of the elements in the specified collection into this list, + * starting at the specified position. Shifts the element currently at that + * position (if any) and any subsequent elements to the right (increases + * their indices). The new elements will appear in the list in the order + * that they are returned by the specified collection's iterator. + * + * @param index - index at which to insert the first element from the + * specified collection + * @param c - collection containing elements to be added to this list + * @return true if this list changed as a result of the call + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LESS 0 || index GREATER size()) + * @throws NullPointerException - if the specified collection is null + */ + @Override + public boolean addAll(int index, Collection c) + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("IndexOutOfBoundsException, index: " + index); + } + if (c == null) + { + throw new NullPointerException("Null parameter " + c); + } + Node temp = tail; + for (E e : c) + { + add(index++, e); + } + size.add(new BigInteger( Integer.toString(c.size()))); + + return temp != tail; + } + + /** + * Returns the element at the specified position in this list. + * + * @param index - index of the element to return + * @return the element at the specified position in this list + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LT 0 || index GE size()) + */ + @Override + public E get(int index) + { + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + return temp.e; + } + + /** + * Replaces the element at the specified position in this list with the + * specified element (optional operation). + * + * @param index - index of the element to replace + * @param element + * @return element - the element previously at the specified position + * @throws ClassCastException - if the class of the specified element + * prevents it from being added to this list + * @throws NullPointerException - if the specified element is null and this + * list does not permit null elements + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this list + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index GE size()) + */ + @Override + public E set(int index, E element) + { + + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + if (element == null) + { + throw new NullPointerException("Null parameter " + element); + } + + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + E e = temp.e; + temp.e = element; + return e; + } + + /** + * Inserts the specified element at the specified position in this list. + * Shifts the element currently at that position (if any) and any subsequent + * elements to the right (adds one to their indices). + * + * @param index at which the specified element is to be inserted + * @param element - element to be appended to this list + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index G size()) + */ + @Override + public void add(int index, E element) + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("Out of bounds: " + Integer.toString(index)); + } + if (element == null) + { + throw new NullPointerException("Null parameter " + element); + } + Node newNode = new Node(); + newNode.e = element; + if (head == null) + { + tail = head = newNode; + } + else + { + if (index == 0)//add in the front + { + newNode.r = head; + head.l = newNode; + head = newNode; + } + else if (index == size())//add in the end + { + newNode.l = tail; + tail.r = newNode; + tail = newNode; + } + else //add in the middle + { + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + + newNode.r = temp; + newNode.l = temp.l; + temp.l.r = newNode; + temp.l = newNode; + + } + } + size.add(new BigInteger( "1")); + + } + + /** + * Removes the element at the specified position in this list. Shifts any + * subsequent elements to the left (subtracts one from their indices). + * Returns the element that was removed from the list. + * + * @param index the index of the element to be removed + * @return the element previously at the specified position, null if empty + * list + * @throws IndexOutOfBoundsException - if the index is out of range (index + * LESS 0 or index GE size() + */ + @Override + public E remove(int index) + { + if (index < 0 || index >= size()) + { + throw new IndexOutOfBoundsException("Index Out of bounds exception : " + index); + } + if (size() == 0) + { + return null; + } + size.subtract(new BigInteger( "1")); + if (size() == 1 && index == 0)//special case just having 1 node + { + Node temp = head; + head = tail = null; + return temp.e; + } + else if (index == 0)//remove the first node + { + Node temp = head; + head = head.r; + head.l = null; + return temp.e; + } + else if (index == size() - 1)//remove last node + { + Node temp = tail; + tail = tail.l; + tail.r = null; + return temp.e; + } + else //remove in the middle + { + Node temp = head; + for (int i = 0; i < index; ++i) + { + temp = temp.r; + } + + temp.l.r = temp.r; + temp.r.l = temp.l; + return temp.e; + } + } + + /** + * Returns the index of the first occurrence of the specified element in + * this list, or -1 if this list does not contain the element. More + * formally, returns the lowest index i such that (o==null ? get(i)==null : + * o.equals(get(i))), or -1 if there is no such index. + * + * + * @param o - element to search for + * @return the index of the first occurrence of the specified element in + * this list, or -1 if this list does not contain the element + * @throws ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + */ + @Override + public int indexOf(Object o) + { + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + E e = it.next(); + if (e.equals(o)) + { + return i; + } + i++; + } + return -1; + } + + /** + * Returns the index of the last occurrence of the specified element in this + * list, or -1 if this list does not contain the element. More formally, + * returns the highest index i such that (o==null ? get(i)==null : + * o.equals(get(i))), or -1 if there is no such index. + * + * + * + * @param o - element to search for + * @return the index of the last occurrence of the specified element in this + * list, or -1 if this list does not contain the element + * @throws:ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + * + */ + @Override + public int lastIndexOf(Object o) + { + Iterator it = this.descendingIterator(); + int index = size() - 1; + while (it.hasNext()) + { + if (it.next().equals(o)) + { + return index; + } + --index; + } + return -1; + } + + /** + * Returns a list-iterator of the elements in this list (in proper + * sequence), starting at the specified position in the list. Obeys the + * general contract of List.listIterator(int). implements : hasNext, next,, + * previous, hasPrevious, nextIndex, previousIndex + * + * @param index - index of the first element to be returned from the + * list-iterator (by a call to next) + * @return a ListIterator of the elements in this list (in proper sequence), + * starting at the specified position in the list + * + * @throws IndexOutOfBoundsException - if the index is out of range (index L + * 0 || index G size()) + */ + @Override + public ListIterator listIterator(int index) + { + ListIterator it = new ListIterator() + { + Node trailNext = trailNextInitialize(); + Node trailPrevious = trailNext.l; + + int nextIndex = index; + int previousIndex = nextIndex - 1; + + Node trailNextInitialize() + { + if (index < 0 || index > size()) + { + throw new IndexOutOfBoundsException("ListIterator index out of bounds: " + index); + } + trailNext = head; + for (int i = 0; i < index; ++i) + { + trailNext = trailNext.r; + } + return trailNext; + } + + /** + * Returns true if this list iterator has more elements when + * traversing the list in the forward direction. (In other words, + * returns true if next() would return an element rather than + * throwing an exception.) + * + * @return returns true if next() would return an element; + */ + @Override + public boolean hasNext() + { + if (trailNext == null) + { + trailNext = head; + trailPrevious = trailNext.l; + nextIndex = 0; + previousIndex = -1; + return false; + } + return true; + } + + /** + * Returns the next element in the list and advances the cursor + * position. This method may be called repeatedly to iterate through + * the list, or intermixed with calls to previous() to go back and + * forth. (Note that alternating calls to next and previous will + * return the same element repeatedly.) Specified by: next in + * interface IteratorLE E> + * NoSuchElementException - if the iteration has no next element + * + * @return the next element in the list + * @throws NoSuchElementException if the iteration has no next element + */ + @Override + public E next() + { + if ( trailNext == null ) + throw new NoSuchElementException( "mo next element exists"); + + Node temp = trailNext; + trailPrevious = trailNext; + trailNext = trailNext.r;//advance the trailNext to the next node + previousIndex = nextIndex;//advance previous index to next + nextIndex++;// advance the next index + + return temp.e; + } + + @Override + public boolean hasPrevious() + { + + if (trailPrevious == null) + { + trailNext = head; + trailPrevious = trailNext.l; + nextIndex = 0; + previousIndex = -1; + return false; + } + return true; + } + + @Override + public E previous() + { + if ( trailPrevious == null ) + throw new NoSuchElementException( "no next element exists"); + + Node temp = trailPrevious; + trailNext = trailPrevious; + trailPrevious = trailPrevious.l; + nextIndex = previousIndex; + previousIndex--; + return temp.e; + } + + @Override + public int nextIndex() + { + return nextIndex; + } + + @Override + public int previousIndex() + { + return previousIndex; + } + + @Override + public void remove() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void set(E e) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void add(E e) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }; + return it; + } + + /** + * One line of code here. Call listIterator(0) + * + * @return ListIterator + */ + @Override + public ListIterator listIterator() + { + return listIterator(0); + } + + /** + * Returns a view of the portion of this list between the specified + * fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex + * are equal, the returned list is empty.) The returned list is backed by + * this list, so non-structural changes in the returned list are reflected + * in this list, and vice-versa. The returned list supports all of the + * optional list operations supported by this list. + * + * + * @param fromIndex - low endpoint (inclusive) of the subList + * @param toIndex - high endpoint (exclusive) of the subList + * @return a view of the specified range within this list + * @throws Throws: IndexOutOfBoundsException - for an illegal endpoint index + * value (fromIndex L 0 || toIndex G size || fromIndex > toIndex) + */ + @Override + public List subList(int fromIndex, int toIndex) + { + if (fromIndex > toIndex || fromIndex < 0 || toIndex > size()) + { + throw new IndexOutOfBoundsException("Index out of Bounds exception " + fromIndex + " " + toIndex); + } + + E[] a = (E[]) new Object[0]; + a = toArray(a); + a = Arrays.copyOfRange(a, fromIndex, toIndex); + return Arrays.asList(a); + } + + @Override + public int size() + { + Node temp = head; + int count = 0; + while (temp != null) + { + count++; + temp = temp.r; + } + return count; + } + + /** + * Tests is the list is empty + * + * @return true if the list is empty, false otherwise. + */ + @Override + public boolean isEmpty() + { + return head == null; + } + + /** + * + * Returns true if this list contains the specified element. More formally, + * returns true if and only if this list contains at least one element e + * such that (o==null ? e==null : o.equals(e)). + * + * @param o - element whose presence in this list is to be tested + * @return true if this list contains the specified element + * @throws ClassCastException - if the type of the specified element is + * incompatible with this list (optional) + */ + @Override + public boolean contains(Object o) + { + Iterator it = this.iterator(); + while (it.hasNext()) + { + if (it.next().equals(o)) + { + return true; + } + } + return false; + } + + /** + * Returns an array containing all of the elements in this list in proper + * sequence (from first to last element). + * + * The returned array will be "safe" in that no references to it are + * maintained by this list. (In other words, this method must allocate a new + * array even if this list is backed by an array). The caller is thus free + * to modify the returned array. + * + * @return an array containing all of the elements in this list in proper + * sequence + */ + @Override + public Object[] toArray() + { + Object[] ar = new Object[size()]; + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + ar[i++] = it.next(); + } + return ar; + } + + /** + * Returns an array containing all of the elements in this list in proper + * sequence (from first to last element); the runtime type of the returned + * array is that of the specified array. If the list fits in the specified + * array, it is returned therein. Otherwise, a new array is allocated with + * the runtime type of the specified array and the size of this list. If the + * list fits in the specified array with room to spare (i.e., the array has + * more elements than the list), the element in the array immediately + * following the end of the list is set to null. (This is useful in + * determining the length of the list only if the caller knows that the list + * does not contain any null elements.) + * + * Like the toArray() method, this method acts as bridge between array-based + * and collection-based APIs. Further, this method allows precise control + * over the runtime type of the output array, and may, under certain + * circumstances, be used to save allocation costs. + * + * Suppose x is a list known to contain only strings. The following code can + * be used to dump the list into a newly allocated array of String: String[] + * y = x.toArray(new String[0]); Note that toArray(new Object[0]) is + * identical in function to toArray(). + * + * Specified by: toArray in interface Collection Type Parameters: T - the + * runtime type of the array to contain the collection Parameters: a - the + * array into which the elements of this list are to be stored, if it is big + * enough; otherwise, a new array of the same runtime type is allocated for + * this purpose. Returns: an array containing the elements of this list + * Throws: ArrayStoreException - if the runtime type of the specified array + * is not a supertype of the runtime type of every element in this list + * NullPointerException - if the specified array is null + * + * @param - the runtime type of the array to contain the collection + * @param a - the array into which the elements of this list are to be + * stored, if it is big enough; otherwise, a new array of the same runtime + * type is allocated for this purpose. + * + * @return an array containing the elements of this list + * @throws ArrayStoreException - if the runtime type of the specified array + * is not a supertype of the runtime type of every element in this list + * @throws NullPointerException - if the specified array is null + */ + @Override + public T[] toArray(T[] a) + { + if (a == null) + { + throw new NullPointerException("Null pointer exception: parameter is null"); + } + + if (a.length >= this.size()) + { + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + T e = (T) it.next(); + a[i++] = e; + } + return a; + } + else + { + T[] ar = Arrays.copyOf(a, size()); + + Iterator it = iterator(); + int i = 0; + while (it.hasNext()) + { + T e = (T) it.next(); + ar[i++] = e; + } + return ar; + } + + } + + /** + * Appends the specified element to the end of this list. This method is + * equivalent to addLast(E). + * + * @param e element to be appended to this list + * @return true if this collection changed as a result of the call + */ + @Override + public boolean add(E e) + { + Node newNode = new Node(); + newNode.e = e; + if (head == null) + { + head = tail = newNode; + } + else + { + newNode.l = tail; + tail.r = newNode; + tail = newNode; + } + size.add(new BigInteger( "1")); + return true; + } + + /** + * Removes a single instance of the specified element from this collection, + * if it is present (optional operation). More formally, removes an element + * e such that (o==null ? e==null : o.equals(e)), if this collection + * contains one or more such elements. + * + * + * @param o - element to be removed from this collection, if present + * @return true if this collection changed as a result of the call. + * @throws ClassCastException - if the type of the specified element is + * incompatible with this collection (optional) + * @throws NullPointerException - if the specified element is null and this + * collection does not permit null elements (optional) + */ + @Override + public boolean remove(Object o) + { + if (o == null) + { + throw new NullPointerException("Null Pointer exception, cant pass null arguments"); + } + Iterator it = this.iterator(); + int pos = 0; + while (it.hasNext()) + { + if (it.next().equals(o)) + { + remove(pos); + return true; + } + pos++; + } + return false; + } + + /** + * Returns true if this collection contains all of the elements in the + * specified collection. + * + * @param c - collection to be checked for containment in this collection + * @return true if this collection contains all of the elements in the + * specified collection + * @throws ClassCastException - if the types of one or more elements in the + * specified collection are incompatible with this collection (optional) + * @throws NullPointerException - if the specified collection contains one + * or more null elements and this collection does not permit null elements + * (optional), or if the specified collection is null. + */ + @Override + public boolean containsAll(Collection c) + { + for (Object o : c) + { + if (contains(o) == false) + { + return false; + } + } + return true; + } + + /** + * Appends all of the elements in the specified collection to the end of + * this list, in the order that they are returned by the specified + * collection's iterator. The behavior of this operation is undefined if the + * specified collection is modified while the operation is in progress. + * (Note that this will occur if the specified collection is this list, and + * it's nonempty.) + * + * @param c - collection containing elements to be added to this list + * @return true if this list changed as a result of the call + * @throws NullPointerException - if the specified collection is null + */ + @Override + public boolean addAll(Collection c) + { + Node temp = tail; + for (E e : c) + { + add(e); + } + return temp != tail; + } + + /** + * Removes from this list all of its elements that are contained in the + * specified collection (optional operation). + * + * @param c - collection containing elements to be removed from this list + * @return true if this list changed as a result of the call + * @throws ClassCastException - if the class of an element of this list is + * incompatible with the specified collection (optional) + */ + @Override + public boolean removeAll(Collection c) + { + Node temp1 = tail; + Node temp2 = head; + for (Object o : c) + { + while (this.remove(o))//remove all same occurances + ; + } + + return temp1 != tail || temp2 != head; + } + + /** + * Retains only the elements in this list that are contained in the + * specified collection (optional operation). In other words, removes from + * this list all of its elements that are not contained in the specified + * collection. + * + * @param c - collection containing elements to be retained in this list + * @return true if this list changed as a result of the call + * @throws ClassCastException - if the class of an element of this list is + * incompatible with the specified collection (optional) + */ + @Override + public boolean retainAll(Collection c) + { + ListASDV cloner = (ListASDV) this.clone(); + cloner.removeAll(c);//cloner has elements to be deleted in the original list + Iterator it = cloner.iterator(); + while (it.hasNext()) + { + Object o = it.next(); + while (this.remove(o)); + } + return true; + } + + /** + * Clears the list of all elements. + */ + @Override + public void clear() + { + size = new BigInteger( "0"); + head = tail = null; + } + + /** + * Inserts the specified element at the beginning of this list. + * + * @param e - the element to add + */ + @Override + public void addFirst(E e) + { + this.add(0, e); + } + + /** + * Appends the specified element to the end of this list. This method is + * equivalent to add(E). + * + * @param e - the element to add + */ + @Override + public void addLast(E e) + { + this.add(size(), e); + } + + /** + * Inserts the specified element at the front of this deque unless it would + * violate capacity restrictions. When using a capacity-restricted deque, + * this method is generally preferable to the addFirst(E) method, which can + * fail to insert an element only by throwing an exception. + * + * Parameters: e - the element to add Returns: true if the element was added + * to this deque, else false Throws: ClassCastException - if the class of + * the specified element prevents it from being added to this deque + * NullPointerException - if the specified element is null and this deque + * does not permit null elements IllegalArgumentException - if some property + * of the specified element prevents it from being added to this deque + * + * @param e - the element to add + * @return true if the element was added to this deque, else false + * @throws ClassCastException if the class of the specified element prevents + * it from being added to this deque + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this deque + */ + @Override + public boolean offerFirst(E e) + { + addFirst(e); + return true; + } + + /** + * Inserts the specified element at the end of this deque unless it would + * violate capacity restrictions. When using a capacity-restricted deque, + * this method is generally preferable to the addLast(E) method, which can + * fail to insert an element only by throwing an exception. + * + * Parameters: e - the element to add Returns: true if the element was added + * to this deque, else false Throws: ClassCastException - if the class of + * the specified element prevents it from being added to this deque + * NullPointerException - if the specified element is null and this deque + * does not permit null elements IllegalArgumentException - if some property + * of the specified element prevents it from being added to this deque + * + * @param e - the element to add + * @return true if the element was added to this deque, else false + * @throws ClassCastException - if the class of the specified element + * prevents it from being added to this deque + * @throws IllegalArgumentException - if some property of the specified + * element prevents it from being added to this deque * + */ + @Override + public boolean offerLast(E e) + { + addLast(e); + return true; + } + + /** + * E removeFirst() + * + * Retrieves and removes the first element of this deque. This method + * differs from pollFirst only in that it throws an exception if this deque + * is empty. + * + * @return the head of this deque + * @throws NoSuchElementException - if this deque is empty + */ + @Override + public E removeFirst() + { + if (this.isEmpty()) + { + throw new NoSuchElementException("list is empty"); + } + return this.remove(0); + } + + /** + * Retrieves and removes the last element of this deque. This method differs + * from pollLast only in that it throws an exception if this deque is empty. + * + * @return the tail of this deque + * @thows NoSuchElementException - if this deque is empty + */ + @Override + public E removeLast() + { + if (this.isEmpty()) + { + throw new NoSuchElementException("list is empty"); + } + return this.remove(size() - 1); + } + + /** + * Retrieves and removes the first element of this deque, or returns null if + * this deque is empty. + * + * @return the head of this deque, or null if this deque is empty + */ + @Override + public E pollFirst() + { + return isEmpty() ? null : this.remove(0); + } + + /** + * Retrieves and removes the last element of this deque, or returns null if + * this deque is empty. + * + * @return the tail of this deque, or null if this deque is empty + */ + @Override + public E pollLast() + { + return isEmpty() ? null : this.remove(size() - 1); + } + + /** + * Retrieves, but does not remove, the first element of this deque. This + * method differs from peekFirst only in that it throws an exception if this + * deque is empty. + * + * @return the head of this deque + * @throws NoSuchElementException - if this deque is empty + */ + @Override + public E getFirst() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty"); + } + + return head.e; + } + + /** + * Retrieves, but does not remove, the last element of this deque. This + * method differs from peekLast only in that it throws an exception if this + * deque is empty. + * + * @return the tail of this deque + * @throws Throws: NoSuchElementException - if this deque is empty + */ + @Override + public E getLast() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty"); + } + return tail.e; + } + + /** + * Retrieves, but does not remove, the first element of this deque, or + * returns null if this deque is empty. + * + * @return the head of this deque, or null if this deque is empty + * + */ + @Override + public E peekFirst() + { + return isEmpty() ? null : this.get(0); + } + + /** + * Retrieves, but does not remove, the last element of this deque, or + * returns null if this deque is empty. + * + * @return the tail of this deque, or null if this deque is empty + */ + @Override + public E peekLast() + { + return isEmpty() ? null : this.get(size() - 1); + } + + /** + * Removes the first occurrence of the specified element from this deque. If + * the deque does not contain the element, it is unchanged. More formally, + * removes the first element e such that (o==null ? e==null : o.equals(e)) + * (if such an element exists). Returns true if this deque contained the + * specified element (or equivalently, if this deque changed as a result of + * the call). + * + * @param o - element to be removed from this deque, if present + * @return true if an element was removed as a result of this call + * @throws ClassCastException - if the class of the specified element is + * incompatible with this deque + */ + @Override + public boolean removeFirstOccurrence(Object o) + { + return isEmpty() ? false : this.remove(o); + + } + + /** + * Removes the last occurrence of the specified element from this deque. If + * the deque does not contain the element, it is unchanged. More formally, + * removes the last element e such that (o==null ? e==null : o.equals(e)) + * (if such an element exists). Returns true if this deque contained the + * specified element (or equivalently, if this deque changed as a result of + * the call) + * + * @param o - element to be removed from this deque, if present + * @return true if an element was removed as a result of this call + * @throws ClassCastException - if the class of the specified element is + * incompatible with this deque (optional) + */ + @Override + public boolean removeLastOccurrence(Object o) + { + Node temp = tail; + int index = size() - 1; + while (temp != null) + { + if (this.get(index).equals(o)) + { + this.remove(index); + return true; + } + index--; + temp = temp.l; + } + return false; + } + + /** + * Inserts the specified element into this queue if it is possible to do so + * immediately without violating capacity restrictions. When using a + * capacity-restricted queue, this method is generally preferable to add(E), + * which can fail to insert an element only by throwing an exception. + * + * + * @param e - the element to add + * @return true if the element was added to this queue, else false + * @throws: ClassCastException - if the class of the specified element + * prevents it from being added to this queue + */ + @Override + public boolean offer(E e) + { + return this.offerLast(e); + } + + /** + * Retrieves and removes the head of this queue. This method differs from + * poll only in that it throws an exception if this queue is empty. + * + * @return the head of this queue + * @throws NoSuchElementException - if this queue is empty + * + */ + @Override + public E remove() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Retrieves and removes the head of this queue, or returns null if this + * queue is empty. + * + * @return the head of this queue, or null if this queue is empty + * + */ + @Override + public E poll() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Retrieves, but does not remove, the head of this queue. This method + * differs from peek only in that it throws an exception if this queue is + * empty. + * + * @return the head of this queue + * @throws: NoSuchElementException - if this queue is empty + * + */ + @Override + public E element() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.get(0); + } + + /** + * Retrieves, but does not remove, the head of this queue, or returns null + * if this queue is empty. + * + * @return the head of this queue, or null if this queue is empty + */ + @Override + public E peek() + { + return isEmpty() ? null : this.get(0); + } + + /** + * Pushes an element onto the stack represented by this list. In other + * words, inserts the element at the front of this list. + * + * This method is equivalent to addFirst(E). Specified by: push in interface + * Deque + * + * @param e - the element to push + */ + @Override + public void push(E e) + { + this.addFirst(e); + } + + /** + * Pops an element from the stack represented by this list. In other words, + * removes and returns the first element of this list. + * + * This method is equivalent to removeFirst(). Specified by: pop in + * interface Deque + * + * @return the element at the front of this list (which is the top of the + * stack represented by this list) + * @throws: NoSuchElementException - if this list is empty + */ + @Override + public E pop() + { + if (isEmpty()) + { + throw new NoSuchElementException("The list is empty!"); + } + return this.remove(0); + } + + /** + * Description copied from interface: Deque Returns an iterator over the + * elements in this deque in reverse sequential order. The elements will be + * returned in order from last (tail) to first (head). + * + * Specified by: descendingIterator in interface Deque + * + * @return an iterator over the elements in this deque in reverse sequence + */ + @Override + public Iterator descendingIterator() + { + + Iterator it = new Iterator() + { + Node trailPrevious = tail; + + @Override + public boolean hasNext() + { + if (trailPrevious == null) + { + trailPrevious = tail; + return false; + } + return true; + } + + @Override + public E next() + { + Node temp = trailPrevious; + trailPrevious = trailPrevious.l; + return temp.e; + } + }; + return it; + } + + /** + * Returns a deep clone of the list. + * + * @return the cloned list + */ + @Override + public Object clone() + { + ListASDV listCloned = new ListASDV(); + Iterator it = this.iterator(); + while (it.hasNext()) + { + + listCloned.add((E) it.next()); + } + return listCloned; + } + + @Override + public String toString() + { + + String s = "ListASDV{ "; + Iterator it = iterator(); + while (it.hasNext()) + { + s += it.next() + " "; + } + s += '}'; + return s; + } + + public static void main(String[] args) + { + class ASDV_ENTRY implements Entry + { + T1 key; + T2 value; + public ASDV_ENTRY( T1 t1, T2 t2) + { + key = t1; + value = t2; + } + @Override + public T1 getKey() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T1 getValue() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T1 setValue(T1 value) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + + } + Entry e1 = new ASDV_ENTRY("john", 20); + + ListASDV listTest = new ListASDV(); + listTest.add(e1); + + + ListASDV list = new ListASDV(); + list.add(100); + list.addFirst(50); + list.add(1, 75); + list.addLast(200); + List collection = Arrays.asList(new Integer[] + { + 300, 400 + }); + list.addAll(collection); + try + { + list.addAll(8, collection); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + Iterator it = list.iterator(); + System.out.println("\ntest add methods ***************************************"); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + + System.out.println(""); + System.out.println("\nforEachRemaining(action) ***************************************"); + + Consumer action = new Consumer() + { + @Override + public void accept(Integer t) + { + System.out.print("*" + t + " "); + } + + }; + it = list.iterator(); + it.next(); + it.next(); + it.forEachRemaining(action); + System.out.println(""); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + System.out.println(""); + it.forEachRemaining(action); + + System.out.println(""); + System.out.println("indexOf ***************************************"); + System.out.println(list.indexOf(new A())); + System.out.println(list.indexOf(200)); + System.out.println(list.indexOf(800)); + + System.out.println("\nclone() ***************************************"); + ListASDV listCloned = (ListASDV) list.clone(); + list.clear(); + it = listCloned.iterator(); + while (it.hasNext()) + { + Object o = it.next(); + System.out.print(o + " "); + } + System.out.println("\nsize of original list after clear: " + list.size()); + list.addAll(0, listCloned); + System.out.println("\ntoString() ***************************************\n" + list); + + System.out.println("\ncontains ***************************************"); + System.out.println(list.contains(new A())); + System.out.println(list.contains(200)); + System.out.println(list.contains(800)); + + System.out.println("\ncontainsAll ***************************************"); + try + { + System.out.println(list.containsAll((Collection) new A())); + } + catch (ClassCastException e) + { + System.out.println(e.getMessage()); + } + System.out.println(list.containsAll(listCloned)); + System.out.println(list.containsAll(Arrays.asList(new Integer[] + { + 100, 300 + }))); + System.out.println(list.containsAll(Arrays.asList(new Integer[] + { + 10, 300 + }))); + + System.out.println("\ndiscendingIterator ***************************************"); + Iterator descIt = list.descendingIterator(); + while (descIt.hasNext()) + { + Object o = descIt.next(); + System.out.print(o + " "); + } + + System.out.println("\nelement ***************************************"); + System.out.println(list.element()); + System.out.println(list.element()); + listCloned.clear(); + try + { + listCloned.element(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\nget(int) ***************************************"); + System.out.println(list.get(0)); + System.out.println(list.get(list.size() - 1)); + try + { + list.get(list.size()); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\ngetFirst() ***************************************"); + System.out.println(list.getFirst()); + System.out.println(list.getFirst()); + try + { + listCloned.getFirst(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\n getLAst()***************************************"); + System.out.println(list.getLast()); + System.out.println(list.getLast()); + + try + { + listCloned.getLast(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\n isEmpty()***************************************"); + System.out.println(list.isEmpty()); + System.out.println(listCloned.isEmpty()); + + System.out.println("\n lastIndexOf***************************************"); + list.add(1, -888); + list.add(4, -888); + System.out.println(list); + System.out.println(list.lastIndexOf(-888)); + System.out.println(list.lastIndexOf(12)); + System.out.println(list.lastIndexOf(new A())); + + System.out.println("\nlistIterator( index=3) using next***************************************"); + System.out.println(list); + ListIterator itList = list.listIterator(3); + + while (itList.hasNext()) + { + Object o = itList.next(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\nlistIterator( index=3) using previous ***************************************"); + System.out.println(list); + itList = list.listIterator(3); + + while (itList.hasPrevious()) + { + Object o = itList.previous(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\nlistIterator with next ***************************************"); + System.out.println(list); + itList = list.listIterator(); + + while (itList.hasNext()) + { + Object o = itList.next(); + System.out.print("next Index " + itList.nextIndex()); + System.out.print(" previous Index " + itList.previousIndex()); + System.out.println(" node " + o + " "); + } + + System.out.println("\noffer methods ***************************************"); + list.offer(500); + list.offerLast(600); + list.offerFirst(33); + System.out.println(list); + + System.out.println("\npeek poll methods ***************************************"); + System.out.println(list.peek()); + System.out.println(list.peekFirst()); + System.out.println(list.peekLast()); + System.out.println(listCloned.peekLast()); + System.out.println(list.poll()); + System.out.println(list.pollFirst()); + System.out.println(list.pollLast()); + System.out.println(listCloned.pollFirst()); + + System.out.println("\npush pop methods ***************************************"); + System.out.println(list); + Integer o = list.pop(); + list.push(o); + System.out.println(list); + try + { + listCloned.pop(); + } + catch (NoSuchElementException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\nremove methods ***************************************"); + System.out.println(list); + System.out.println(list.removeLastOccurrence(-888)); + System.out.println(list); + System.out.println(list.remove()); + System.out.println(list.removeFirst()); + System.out.println(list); + System.out.println(list.remove((Integer) 300)); + try + { + list.remove(null); + } + catch (NullPointerException e) + { + System.out.println(e.getMessage()); + } + try + { + list.remove(200); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + System.out.println(list); + + System.out.println("\nremoveAll( Collection c) ***************************************"); + list.add(0, -888); + list.add(2, -888); + list.add(-888); + listCloned = (ListASDV) list.clone(); + System.out.println(list); + List col = Arrays.asList(new Integer[] + { + -888, 200 + }); + list.removeAll(col); + System.out.println(list); + + System.out.println("\nretailAll( Collection c) ***************************************"); + list = (ListASDV) listCloned.clone(); + list.retainAll(col); + System.out.println(list); + + System.out.println("\nset ***************************************"); + list.set(0, 100); + System.out.println(list); + + System.out.println("\nsubList ***************************************"); + List subList = list.subList(1, 3); + System.out.println(subList); + try + { + list.subList(1, 5); + } + catch (IndexOutOfBoundsException e) + { + System.out.println(e.getMessage()); + } + + System.out.println("\ntoArray ***************************************"); + System.out.println(list); + System.out.println(Arrays.asList(list.toArray())); + + Integer[] ar = new Integer[list.size()]; + System.out.println("\ntoArray(T[] ) ***************************************"); + System.out.println(list); + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = new Integer[1]; + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = new Integer[list.size() + list.size()]; + System.out.println(Arrays.asList(list.toArray(ar))); + + ar = null; + try + { + list.toArray(ar); + } + catch (NullPointerException e) + { + System.out.println(e.getMessage()); + } + + } + +} + +class A +{ +} diff --git a/Semester 3/Assignments/Ajz5/nb-configuration.xml b/Semester 3/Assignments/Ajz5/nb-configuration.xml new file mode 100644 index 0000000..f7b0362 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/nb-configuration.xml @@ -0,0 +1,21 @@ + + + + + + 10-web + gfv700ee10 + Facelets + JDK_15__System_ + + diff --git a/Semester 3/Assignments/Ajz5/pom.xml b/Semester 3/Assignments/Ajz5/pom.xml new file mode 100644 index 0000000..c5d5892 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/pom.xml @@ -0,0 +1,83 @@ + + 4.0.0 + asdv + 5 + 1 + war + Ajax5-1-Many + + + 11 + 11 + ${project.build.directory}/endorsed + UTF-8 + false + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + org.primefaces + primefaces + 13.0.2 + jakarta + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.6 + + + validate + + copy + + + ${endorsed.dir} + true + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + jar + + + + + + + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Ajz5/src/main/java/asdv/ajax/resources/JakartaEE10Resource.java b/Semester 3/Assignments/Ajz5/src/main/java/asdv/ajax/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..f708ef2 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/java/asdv/ajax/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package asdv.ajax.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 3/Assignments/Ajz5/src/main/java/beans/PartialProcessingBean.java b/Semester 3/Assignments/Ajz5/src/main/java/beans/PartialProcessingBean.java new file mode 100644 index 0000000..dd23fe1 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/java/beans/PartialProcessingBean.java @@ -0,0 +1,276 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package beans; + +import model.factoryOneToMany.OneToMany; +import model.factoryOneToMany.OneToManyFactory; +import jakarta.faces.event.AbortProcessingException; +import jakarta.faces.event.AjaxBehaviorEvent; +import jakarta.faces.view.ViewScoped; +import jakarta.inject.Named; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Named +@ViewScoped +public class PartialProcessingBean implements Serializable +{ + private String country; + private String city; + private String[] countries = + { + "USA", "Greece", "France" + }; + private String[] citiesFrance = + { + "Paris", "Marseille" + }; + private String[] citiesGreece = + { + "Athens", "Sparta" + }; + private String[] citiesUsa = + { + "Lafayette", "New Orleans" + }; + private OneToMany oneToMany = OneToManyFactory.createOneToMany(); + private String name = ""; + private String totalValue = "120.00"; + private String email = ""; + private String emailAgain = ""; + private Date date; + private String tickets = "1"; + private String price = "120"; + private Map ticketAttrs; + private Map priceAttrs; + + public PartialProcessingBean() + { + oneToMany.initializeOne(this.countries); + oneToMany.initializeMany(this.countries[0], citiesUsa); + oneToMany.initializeMany(this.countries[1], citiesGreece); + oneToMany.initializeMany(this.countries[2], citiesFrance); + + + + ticketAttrs = new HashMap<>(); + this.ticketAttrs.put("type", "number"); + this.ticketAttrs.put("min", "1"); + this.ticketAttrs.put("max", "4"); + this.ticketAttrs.put("required", "required"); + this.ticketAttrs.put("title", + "Enter a number between 1 and 4 inclusive."); + this.priceAttrs = new HashMap<>(); + this.priceAttrs.put("type", "number"); + this.priceAttrs.put("min", "120"); + this.priceAttrs.put("max", "1000"); + this.priceAttrs.put("required", "required"); + this.priceAttrs.put("step", 10); + this.priceAttrs.put("title", + "Enter a number between 120 and 100 inclusive."); + } + + public OneToMany getOneToMany() + { + System.out.println("getOneToMany()"); + return oneToMany; + } + + public String getCountry() + { + System.out.println("getCountry()"); + return country; + } + + public void setCountry(String country) + { + System.out.println("setCountry(String country) " + country ); + this.country = country; + } + + public String getCity() + { + return city; + } + + public void setCity(String city) + { + System.out.println("setCity(String city) " + city ); + + this.city = city; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + System.out.println("setEmail(String email) " + city ); + + this.email = email; + } + + public void handleCountryChange() + { + if (country != null && !country.equals("")) + { + getMany(); + } + } + + public Collection getMany() + { + if (country != null && !country.equals("")) + { + return this.oneToMany.getMany(country); + } + return Arrays.asList(citiesUsa); + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + System.out.println("setName(String name) " + name ); + + this.name = name; + } + + public String getTotalValue() + { + System.out.println("getTotalValue(String totalValue) " ); + return totalValue; + } + + public void setTotalValue(String totalValue) + { + System.out.println("setTotalValue(String totalValue) " + totalValue ); + this.totalValue = totalValue; + } + + public String getEmailAgain() + { + System.out.println("getEmailAgain() " ); + + return emailAgain; + } + + public void setEmailAgain(String emailAgain) + { + System.out.println("setEmailAgain(String emailAgain) " + emailAgain ); + + this.emailAgain = emailAgain; + } + + public Date getDate() + { + System.out.println("getDate() "); + + return date; + } + + public void setDate(Date date) + { + System.out.println("setDate(Date date) " + date ); + + this.date = date; + } + + public String getTickets() + { + System.out.println("getTickets() " ); + + return tickets; + } + + public void setTickets(String tickets) + { + System.out.println("setTickets(String tickets) " + tickets ); + this.tickets = tickets; + } + + public String getPrice() + { + System.out.println("getPrice() " ); + + return price; + } + + public void setPrice(String price) + { + System.out.println("setPrice(String price) " + price); + + this.price = price; + } + + public Map getTicketAttrs() + { + System.out.println("getTicketAttrs() " ); + + return ticketAttrs; + } + + public void setTicketAttrs(Map ticketAttrs) + { + System.out.println("setTicketAttrs(Map ticketAttrs) " + ticketAttrs); + + this.ticketAttrs = ticketAttrs; + } + + public Map getPriceAttrs() + { + System.out.println("getPriceAttrs() " ); + + return priceAttrs; + } + + public void setPriceAttrs(Map priceAttrs) + { + System.out.println("setPriceAttrs(Map priceAttrs) " + ticketAttrs); + + this.priceAttrs = priceAttrs; + } + + public void calculateTotal(AjaxBehaviorEvent event) + throws AbortProcessingException + { + System.out.println("calculateTotal(AjaxBehaviorEvent event)"); + int ticketsNum = 1; + int ticketPrice = 0; + int total; + if (tickets.trim().length() > 0) + { + ticketsNum = Integer.parseInt(tickets); + } + if (price.trim().length() > 0) + { + ticketPrice = Integer.parseInt(price); + } + total = (ticketsNum * ticketPrice); + totalValue = String.valueOf(total) + ".00"; + } + + public void clear(AjaxBehaviorEvent event) + throws AbortProcessingException + { + System.out.println("clear(AjaxBehaviorEvent event)"); + name = ""; + email = ""; + emailAgain = ""; + date = null; + price = "120.00"; + totalValue = "120.00"; + tickets = "1"; + } +} diff --git a/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToMany.java b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToMany.java new file mode 100644 index 0000000..af90948 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToMany.java @@ -0,0 +1,68 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package model.factoryOneToMany; + +import java.util.Collection; +import java.util.Set; + +/** + * + * @author asdv5 + * @param + * @param + */ +public interface OneToMany +{ + /** + * Initialization of Ones. The method should be used first before any other + * methods + * + * @param one - the ones ( i.e, countries, or SelectItem or any Object) to + * use for initialization + * @return true if the initialization succeeded by using the method once, + * false when the method is used more than once. + */ + boolean initializeOne(One... one); + + /** + * Initialization of the many for a given one. The method can be used + * multiple times after the method initializeOne has succeeded. + * + * @param one - the one that has the many + * @param many - the many which belong to th eone + * @throws IllegalArgumentException when the one does not exist (i.e. user's + * typing error for the name of one) or when the initialization of the one + * has not occurred. + * + */ + void initializeMany(One one, Many... many) + throws IllegalArgumentException; + + + /** + * Gets the many of a specific one. + * + * @param one the one to get its many + * @return the many of the parameter one or null if the one does not exist. + */ + Collection getMany(One one); + + + + /** + * Given a value of the many it gets the one that the many belongs to. + * + * @param many one of the values of the many + * @return the one + */ + One getOne(Many many); + + /** + * Gets a set with all the ones + * + * @return the set of ones. + */ + Set getAllOnes(); +} diff --git a/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToManyFactory.java b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToManyFactory.java new file mode 100644 index 0000000..5b311c5 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/OneToManyFactory.java @@ -0,0 +1,204 @@ +package model.factoryOneToMany; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +public class OneToManyFactory +{ + /** + * Creates an object of type OneToMany + * + * @param a generic parameter can be any object that denotes a One. + * @param a generic parameter can be any object that denotes a city + * that belongs to the one generic type. + * @return a OneCity object. + */ + public static //generic types to be used in the method + OneToMany //rturn type + createOneToMany() + { + return new OneToMany() + { + private Map oneToMany = new LinkedHashMap(); + boolean oneInitialized = false; + boolean manyInitialized = false; + + @Override + public boolean initializeOne(One... one) + { + if (oneInitialized == false && manyInitialized == false) + { + for (int i = 0; i < one.length; ++i) + { + oneToMany.put(one[i], new Boolean(true)); + } + oneInitialized = true; + return true; + } + return false; + } + + @Override + public void initializeMany(One one, Many... many) + throws IllegalArgumentException + { + if (oneToMany.get(one) == null)//if the key of the one is null + {//the method initializekey has not been used + throw new IllegalArgumentException(one + " is not valid"); + } + oneToMany.put(one, new ArrayList(Arrays.asList(many))); + manyInitialized = true; + } + + @Override + public Collection getMany(One one) + throws IllegalArgumentException + { + if (oneInitialized == true && manyInitialized == true) + { + if (oneToMany.get(one) == null) + { + throw new IllegalArgumentException(one + " is not a valid One"); + } + Collection c1 = (Collection) oneToMany.get(one); + return c1; + } + return null; + } + + @Override + public One getOne(Many many) + { + Set< Entry> set = oneToMany.entrySet(); + for (Map.Entry entry : oneToMany.entrySet()) + { + One key = (One) entry.getKey(); + Collection value = (Collection) oneToMany.get(key); + if (value.contains(many)) + { + return key; + } + } + return null; + } + + @Override + public Set getAllOnes() + { + return (Set) oneToMany.keySet(); + } + }; + } + + public static void main(String[] args) + { + OneToMany cc = OneToManyFactory.createOneToMany(); + try + { + cc.initializeMany("France", "Paris"); + } + catch (Exception e) + { + System.err.println(e); + } + boolean b1 = cc.initializeOne("USA", "Greece"); + System.out.println(b1); + boolean b2 = cc.initializeOne("USA", "Greece"); + System.out.println(b2); + cc.initializeMany("USA", "Lafayette", "New Orleans"); + cc.initializeMany("Greece", "Athens", "Sparta"); + Collection cities1 = cc.getMany("USA"); + System.out.println(cities1); + Collection cities2 = cc.getMany("Greece"); + System.out.println(cities2); + System.out.println(cc.getOne("Athens")); + System.out.println(cc.getOne("Lafayette")); + System.out.println(cc.getOne("France")); + try + { + System.out.println(cc.getMany("Germany")); + } + catch (Exception e) + { + System.err.println(e); + } + System.out.println(cc.getAllOnes()); + System.out.println("--------------------------------------"); + OneToMany supplierParts = OneToManyFactory.createOneToMany(); + Supplier s1 = new Supplier("s1"); + Supplier s2 = new Supplier("s2"); + supplierParts.initializeOne(s1, s2); + + Part p1 = new Part("p1"); + Part p2 = new Part("p2"); + Part p3 = new Part("p3"); + Part p4 = new Part("p4"); + supplierParts.initializeMany(s1, p1,p2); + supplierParts.initializeMany(s2, p3,p4); + + System.out.println( supplierParts.getMany(s1)); + System.out.println( supplierParts.getMany(s2)); + System.out.println( supplierParts.getOne(p1) ); + + } +} + + class Supplier + { + private String name; + + public Supplier(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + @Override + public String toString() + { + return "Supplier{" + "name=" + name + '}'; + } + } + + class Part + { + private String name; + + public Part(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + @Override + public String toString() + { + return "Part{" + "name=" + name + '}'; + } + + + } + diff --git a/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/TestMap.java b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/TestMap.java new file mode 100644 index 0000000..f636722 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/java/model/factoryOneToMany/TestMap.java @@ -0,0 +1,39 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package model.factoryOneToMany; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; + +/** + * + * @author asdv5 + */ +public class TestMap +{ + public static void main(String[] args) + { + HashMap> map = new HashMap(); + ArrayList l1 = new ArrayList(); + l1.add("p1"); + l1.add("p2"); + map.put("e1", l1); + ArrayList l2 = new ArrayList(); + l2.add("p2"); + l2.add("p3"); + map.put("e2", l2); + System.out.println(map); + + + Collection> c = map.values(); + System.out.println(c); + for (ArrayList a : c ) + a.remove("p2"); + System.out.println(c); + System.out.println(map); + + } +} diff --git a/Semester 3/Assignments/Ajz5/src/main/resources/META-INF/persistence.xml b/Semester 3/Assignments/Ajz5/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/beans.xml b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/web.xml b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/index.xhtml b/Semester 3/Assignments/Ajz5/src/main/webapp/index.xhtml new file mode 100644 index 0000000..f2ff25e --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/index.xhtml @@ -0,0 +1,15 @@ + + + + + Ajax 5 + + + + +

+ +
+
+ diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/jsf-ajax.xhtml b/Semester 3/Assignments/Ajz5/src/main/webapp/jsf-ajax.xhtml new file mode 100644 index 0000000..f354daa --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/jsf-ajax.xhtml @@ -0,0 +1,122 @@ + + + + + JSF Ajax + + + + + + + + + + + + +

Ajax Prime Faces

+

Partial Proccess & Partial Update

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ + + +
+
+ +
+ diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/prime-faces-ajax.xhtml b/Semester 3/Assignments/Ajz5/src/main/webapp/prime-faces-ajax.xhtml new file mode 100644 index 0000000..7ecc010 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/prime-faces-ajax.xhtml @@ -0,0 +1,122 @@ + + + + + Prime Paces Ajax + + + + + + + + + + + + +

Ajax Prime Faces

+

Partial Proccess & Partial Update

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ + + +
+
+ +
+ diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/resources/css/stylesheet.css b/Semester 3/Assignments/Ajz5/src/main/webapp/resources/css/stylesheet.css new file mode 100644 index 0000000..0a6443b --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/resources/css/stylesheet.css @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * + * You may not modify, use, reproduce, or distribute this software except in + * compliance with the terms of the License at: + * http://java.net/projects/javaeetutorial/pages/BerkeleyLicense + */ +input { + -moz-border-radius:6px; + -webkit-border-radius:6px; + border-radius:6px; + font-size:14px; + width:300px; + min-height:24px; +} + +output { + font-size:14px; +} + +body { + background-color: #ffffff; + font-size: 14px; + font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + color: #000000; + margin: 10px; +} + +h2 { + font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; + border-bottom: 1px solid #AFAFAF; + font-size: 18px; + font-weight: bold; + margin: 0px; + padding: 0px; + color: #D20005; +} \ No newline at end of file diff --git a/Semester 3/Assignments/Ajz5/src/main/webapp/resources/js/do_validation.js b/Semester 3/Assignments/Ajz5/src/main/webapp/resources/js/do_validation.js new file mode 100644 index 0000000..5f7a9b9 --- /dev/null +++ b/Semester 3/Assignments/Ajz5/src/main/webapp/resources/js/do_validation.js @@ -0,0 +1,9 @@ + +function check(email1, email2) { + var e1 = document.getElementById(email1).value; + var e2 = document.getElementById(email2).value; + + if (e1 != e2) + alert("Emails don't match."); + +} diff --git a/Semester 3/Assignments/MaxTask/pom.xml b/Semester 3/Assignments/MaxTask/pom.xml new file mode 100644 index 0000000..41b596a --- /dev/null +++ b/Semester 3/Assignments/MaxTask/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.slcc.asdv.caleb + MaxTask + 1.0-SNAPSHOT + jar + + UTF-8 + 20 + 20 + edu.slcc.asdv.caleb.maxtask.MaxTask + + \ No newline at end of file diff --git a/Semester 3/Assignments/MaxTask/src/main/java/edu/slcc/asdv/caleb/maxtask/MaxTask.java b/Semester 3/Assignments/MaxTask/src/main/java/edu/slcc/asdv/caleb/maxtask/MaxTask.java new file mode 100644 index 0000000..58d66f5 --- /dev/null +++ b/Semester 3/Assignments/MaxTask/src/main/java/edu/slcc/asdv/caleb/maxtask/MaxTask.java @@ -0,0 +1,23 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.caleb.maxtask; + +import java.util.concurrent.RecursiveTask; + +/** + * + * @author caleb + */ +public class MaxTask { + + public static void main(String[] args) { + + } + public static int max(int[] list) { + RecursiveTask task = new MaxTask(list 0, list.length) { + + } + } +} diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/01templates.pdf b/Semester 3/Assignments/Templates01_CalebFontenot/01templates.pdf new file mode 100644 index 0000000..c956927 Binary files /dev/null and b/Semester 3/Assignments/Templates01_CalebFontenot/01templates.pdf differ diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/02templates.pdf b/Semester 3/Assignments/Templates01_CalebFontenot/02templates.pdf new file mode 100644 index 0000000..e8647a3 Binary files /dev/null and b/Semester 3/Assignments/Templates01_CalebFontenot/02templates.pdf differ diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/nb-configuration.xml b/Semester 3/Assignments/Templates01_CalebFontenot/nb-configuration.xml new file mode 100644 index 0000000..5e1a2de --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/nb-configuration.xml @@ -0,0 +1,20 @@ + + + + + + 10-web + gfv700ee10 + Facelets + + diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/pom.xml b/Semester 3/Assignments/Templates01_CalebFontenot/pom.xml new file mode 100644 index 0000000..ca01ba0 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + edu.slcc.asdv.caleb + Templates01_CalebFontenot + 1.0-SNAPSHOT + war + Templates01_CalebFontenot-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/beans/RandomNumberGenerator.java b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/beans/RandomNumberGenerator.java new file mode 100644 index 0000000..3216d88 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/beans/RandomNumberGenerator.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template + */ + +package edu.slcc.asdv.beans; + +import jakarta.inject.Named; +import jakarta.enterprise.context.Dependent; + +/** + * + * @author caleb + */ +@Named(value="randomNumberGenerator") +@Dependent +public class RandomNumberGenerator { + + /** Creates a new instance of RandomNumberGenerator */ + public RandomNumberGenerator() { + } + + public double getRandomNum() { + return Math.random(); + } +} diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/JakartaRestConfiguration.java b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..7d1cd4d --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.caleb.templates01_calebfontenot; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/resources/JakartaEE10Resource.java b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..1664662 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/templates01_calebfontenot/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.caleb.templates01_calebfontenot.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/resources/META-INF/persistence.xml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/beans.xml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/web.xml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/index.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/index.xhtml new file mode 100644 index 0000000..f611cb7 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/index.xhtml @@ -0,0 +1,13 @@ + + + + + Templates Test + + + + + + + diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/re-use-snippet-many-times.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/re-use-snippet-many-times.xhtml new file mode 100644 index 0000000..4c9ae84 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/re-use-snippet-many-times.xhtml @@ -0,0 +1,28 @@ + + + + + Multiple Snippets + + + +

Some Random Page

+

This page reuses the included file in multiple places

+ +
+ + +
+ +
+ +
+

Blah, blah, blah. + Blah, blah, blah.
+ More blah, blah, blah. + Blah, blah, blah. +

+
+ diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/css/styles.css b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/css/styles.css new file mode 100644 index 0000000..1daf5b8 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/css/styles.css @@ -0,0 +1,35 @@ +/* +Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license +Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/CascadeStyleSheet.css to edit this template +*/ +/* + Created on : Feb 15, 2024, 12:38:08 PM + Author : caleb +*/ +body { + font-family: Comic Sans MS, Ariel, Helvetica, sans-serif; + background-color: #e9e9e9; +} +a:hover { color: red } +h1,h2,h3 { + text-align: center; + font-family: Comic Sans MS, Ariel, Helvetica, sans-serif; + color: black; +} +title1 { + display: table; + margin:auto; + background-color: yellow; + font-family: Comic Sans MS, Ariel, Helvetica, sans-serif; + font-size: xx-large; + padding: 5px 8px; + letter-spacing: -.025em; +} +.white { + color: white; + font-family: Comic Sans MS, Ariel, Helvetica, sans-serif; + font-size: 80%; + font-weight: bold; + text-decoration: none; +} +.dark { background-color: black; } diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/piece-of-JSF-html.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/piece-of-JSF-html.xhtml new file mode 100644 index 0000000..dcdfef4 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/piece-of-JSF-html.xhtml @@ -0,0 +1,8 @@ + +
+

This is a piece of JSF and HTML content
+ A random number: #{randomNumberGenerator.randomNum} +

+
+
\ No newline at end of file diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/searxng-search-box.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/searxng-search-box.xhtml new file mode 100644 index 0000000..38cf241 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/snippets/searxng-search-box.xhtml @@ -0,0 +1,8 @@ + + +
+
+ +
+
\ No newline at end of file diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/templates/sample-template.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/templates/sample-template.xhtml new file mode 100644 index 0000000..4d25e49 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/resources/templates/sample-template.xhtml @@ -0,0 +1,22 @@ + + + + + + <ui:insert name="title">This will be replaced and appear in the browser's toolbar</ui:insert> + + + + + + + This page is supposed to be replaced + +

This will appear in every page that uses this template
+ --Random number Generator: #{randomNumberGenerator.randomNum}

+ + To be replaced by ui:define using content +
+ diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/sample-page.xhtml b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/sample-page.xhtml new file mode 100644 index 0000000..4722e30 --- /dev/null +++ b/Semester 3/Assignments/Templates01_CalebFontenot/src/main/webapp/sample-page.xhtml @@ -0,0 +1,21 @@ + + + + Sample-Template + + + + Title of page + + + + +

This is the replacing content.

+

Blah, blah, blah.

+

More Blah, blah, blah.

+

Even more Blah, blah, blah.

+
+
\ No newline at end of file diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/templates03.pdf b/Semester 3/Assignments/Templates01_CalebFontenot/templates03.pdf new file mode 100644 index 0000000..e3c1b4c Binary files /dev/null and b/Semester 3/Assignments/Templates01_CalebFontenot/templates03.pdf differ diff --git a/Semester 3/Assignments/Templates01_CalebFontenot/templates04.pdf b/Semester 3/Assignments/Templates01_CalebFontenot/templates04.pdf new file mode 100644 index 0000000..41f36b3 Binary files /dev/null and b/Semester 3/Assignments/Templates01_CalebFontenot/templates04.pdf differ diff --git a/Semester 3/Assignments/mavenproject1/nb-configuration.xml b/Semester 3/Assignments/mavenproject1/nb-configuration.xml new file mode 100644 index 0000000..5e1a2de --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/nb-configuration.xml @@ -0,0 +1,20 @@ + + + + + + 10-web + gfv700ee10 + Facelets + + diff --git a/Semester 3/Assignments/mavenproject1/pom.xml b/Semester 3/Assignments/mavenproject1/pom.xml new file mode 100644 index 0000000..b4b828b --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + edu.slcc.asdv.caleb + mavenproject1 + 1.0-SNAPSHOT + war + mavenproject1-1.0-SNAPSHOT + + + UTF-8 + 10.0.0 + + + + + jakarta.platform + jakarta.jakartaee-api + ${jakartaee} + provided + + + org.primefaces + primefaces + 13.0.5 + jakarta + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.2 + + + + \ No newline at end of file diff --git a/Semester 3/Assignments/mavenproject1/src/main/java/car/Car.java b/Semester 3/Assignments/mavenproject1/src/main/java/car/Car.java new file mode 100644 index 0000000..63c71f5 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/java/car/Car.java @@ -0,0 +1,45 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package car; + +import java.io.Serializable; + +/** + * + * @author caleb + */ +class Car implements Serializable { + + private String name; + private int year; + + public Car(String name, int year) + { + this.name = name; + this.year = year; + } + + public int getYear() + { + return year; + } + + public void setYear(int year) + { + this.year = year; + } + + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} diff --git a/Semester 3/Assignments/mavenproject1/src/main/java/car/CarAutoCompleteBean.java b/Semester 3/Assignments/mavenproject1/src/main/java/car/CarAutoCompleteBean.java new file mode 100644 index 0000000..c328aed --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/java/car/CarAutoCompleteBean.java @@ -0,0 +1,141 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package car; + +/** + * + * @author caleb + */ + +import jakarta.faces.application.FacesMessage; +import jakarta.faces.context.FacesContext; +import jakarta.faces.view.ViewScoped; +import jakarta.inject.Named; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.primefaces.event.SelectEvent; + +@Named(value = "carAutoCompleteBean") +@ViewScoped +public class CarAutoCompleteBean implements Serializable +{ + private Car selectedCar; + private static Map cars = new HashMap(); + + String simpleText; + List multipleSelects; + + public CarAutoCompleteBean() + { + cars.put("BMW", new Car("BMW", 2024)); + cars.put("CC", new Car("CC", 2018)); + cars.put("Golf", new Car("Golf", 1998)); + cars.put("Jetta", new Car("Jetta", 2012)); + cars.put("Passat", new Car("Passat", 2016)); + + cars.put("Polo", new Car("Polo", 1978)); + cars.put("Scirocco", new Car("Scirocco", 1981)); + cars.put("Touareg", new Car("Touareg", 2019)); + } + + public List getMultipleSelects() + { + return multipleSelects; + } + + public void setMultipleSelects(List multipleSelects) + { + this.multipleSelects = multipleSelects; + } + + public static Map getCars() + { + return cars; + } + + public Car getSelectedCar() + { + System.out.println(selectedCar); + return selectedCar; + } + + public void setSelectedCar(Car selectedCar) + { + this.selectedCar = selectedCar; + } + + public List completeCar(String input) + { + List suggestions = new ArrayList(); + Set keys = cars.keySet(); + for (String key : keys) + { + if (key.startsWith(input)) + { + suggestions.add(cars.get(key)); + } + } + return suggestions; + } + + public List completeCarContains(String input) + { + List suggestions = new ArrayList(); + Set keys = cars.keySet(); + for (String key : keys) + { + String s = key.toLowerCase(); + if (s.contains(input.toLowerCase())) + { + suggestions.add(cars.get(key)); + } + } + return suggestions; + } + + public String getSimpleText() + { + return simpleText; + } + + public void setSimpleText(String simpleText) + { + this.simpleText = simpleText; + } + public List completeSimple(String input) + { + List suggestions = new ArrayList(); + + for (char c ='A'; c < 'Z'; ++c) + { + suggestions.add( Character.toString(c)); + } + return suggestions; + } + public void handleSelect(SelectEvent event) + { + System.out.println("handleSelect:" + event ); + Object selectedObject = event.getObject(); + FacesMessage msg = new FacesMessage("Selected", "Item:" + selectedObject); + FacesContext.getCurrentInstance().addMessage(null, msg); + } + + public void handleSelectSimple(SelectEvent event) + { + System.out.println("handleSelect:" + event ); + Object selectedObject = event.getObject(); + FacesMessage msg = new FacesMessage("Selected", "Item:" + selectedObject); + FacesContext.getCurrentInstance().addMessage(null, msg); + } + + + +} + + diff --git a/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/JakartaRestConfiguration.java b/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/JakartaRestConfiguration.java new file mode 100644 index 0000000..3f5dbd2 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.caleb.mavenproject1; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/resources/JakartaEE10Resource.java b/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..1410640 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.caleb.mavenproject1.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 3/Assignments/mavenproject1/src/main/resources/META-INF/persistence.xml b/Semester 3/Assignments/mavenproject1/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000..7582bf1 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/beans.xml b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000..9dfae34 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/glassfish-web.xml b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/glassfish-web.xml new file mode 100644 index 0000000..673cc06 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/glassfish-web.xml @@ -0,0 +1,25 @@ + + + + + + + + Keep a copy of the generated servlet class' java code. + + + diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/web.xml b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..fcfcd54 --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + jakarta.faces.PROJECT_STAGE + Development + + + Faces Servlet + jakarta.faces.webapp.FacesServlet + 1 + + + Faces Servlet + /faces/* + + + + 30 + + + + faces/index.xhtml + + diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/car.xhtml b/Semester 3/Assignments/mavenproject1/src/main/webapp/car.xhtml new file mode 100644 index 0000000..6e423db --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/webapp/car.xhtml @@ -0,0 +1,64 @@ + + + + + + #{msgs.title} + + + + + + + + + + + #{car.name} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/index.html b/Semester 3/Assignments/mavenproject1/src/main/webapp/index.html new file mode 100644 index 0000000..3368e9c --- /dev/null +++ b/Semester 3/Assignments/mavenproject1/src/main/webapp/index.html @@ -0,0 +1,10 @@ + + + + Start Page + + + +

Hello World!

+ + diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/BMW.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/BMW.png new file mode 100644 index 0000000..c3fe8aa Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/BMW.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/CC.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/CC.png new file mode 100644 index 0000000..11281c9 Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/CC.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Golf.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Golf.png new file mode 100644 index 0000000..27ef04a Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Golf.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Jetta.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Jetta.png new file mode 100644 index 0000000..a556804 Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Jetta.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Passat.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Passat.png new file mode 100644 index 0000000..974ae4a Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Passat.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Polo.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Polo.png new file mode 100644 index 0000000..8d73cf5 Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Polo.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Scirocco.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Scirocco.png new file mode 100644 index 0000000..80279d2 Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Scirocco.png differ diff --git a/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Touareg.png b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Touareg.png new file mode 100644 index 0000000..afb557f Binary files /dev/null and b/Semester 3/Assignments/mavenproject1/src/main/webapp/resources/images/Touareg.png differ