https://smconsultant.com/oracle-soa-tutorial/
know-how
Wednesday, July 21, 2021
connect By
It builds a hierarchical query.
There are 2 components to is:
"start with" -- this identifies all LEVEL=1 nodes in the tree
"connect by" -- describes how to walk from the parent nodes above to their children and their children's children.
Easiest to use an example on emp. If we start with "where mgr is NULL", we generate the set of employees that have no mgr (they are at the top of the tree). If we
CONNECT BY PRIOR EMPNO = /* current */ MGR
that will take all of the PRIOR records (the start with at first) and find all records such that the MGR column equals their EMPNO (find all the records of people managed by the people we started with).
Using EMP, the start with SET is:
scott@ORA8I.WORLD> select ename, empno, mgr from emp
2 where mgr is null;
ENAME EMPNO MGR
---------- ---------- ----------
KING 7839
Now, if we do the "connect by manually" we would find:
scott@ORA8I.WORLD> select ename, empno, mgr
2 from emp where mgr = 7839;
ENAME EMPNO MGR
---------- ---------- ----------
JONES 7566 7839
BLAKE 7698 7839
CLARK 7782 7839
scott@ORA8I.WORLD>
KINGS empno is the prior empno. If we build the entire hierarch -- we have:
scott@ORA8I.WORLD> select lpad(' ',level*2,' ')||ename ename, empno, mgr
2 from emp
3 START WITH MGR IS NULL
4 CONNECT BY PRIOR EMPNO = MGR
5 /
ENAME EMPNO MGR
--------------- ---------- ----------
KING 7839
JONES 7566 7839
SCOTT 7788 7566
ADAMS 7876 7788
FORD 7902 7566
SMITH 7369 7902
BLAKE 7698 7839
ALLEN 7499 7698
WARD 7521 7698
MARTIN 7654 7698
TURNER 7844 7698
JAMES 7900 7698
CLARK 7782 7839
MILLER 7934 7782
14 rows selected.
So, KING is the start with the set then JONES BLAKE and CLARK fall under him. Each of them becomes the PRIOR record in turn and their trees are expanded.
There are 2 components to is:
"start with" -- this identifies all LEVEL=1 nodes in the tree
"connect by" -- describes how to walk from the parent nodes above to their children and their children's children.
Easiest to use an example on emp. If we start with "where mgr is NULL", we generate the set of employees that have no mgr (they are at the top of the tree). If we
CONNECT BY PRIOR EMPNO = /* current */ MGR
that will take all of the PRIOR records (the start with at first) and find all records such that the MGR column equals their EMPNO (find all the records of people managed by the people we started with).
Using EMP, the start with SET is:
scott@ORA8I.WORLD> select ename, empno, mgr from emp
2 where mgr is null;
ENAME EMPNO MGR
---------- ---------- ----------
KING 7839
Now, if we do the "connect by manually" we would find:
scott@ORA8I.WORLD> select ename, empno, mgr
2 from emp where mgr = 7839;
ENAME EMPNO MGR
---------- ---------- ----------
JONES 7566 7839
BLAKE 7698 7839
CLARK 7782 7839
scott@ORA8I.WORLD>
KINGS empno is the prior empno. If we build the entire hierarch -- we have:
scott@ORA8I.WORLD> select lpad(' ',level*2,' ')||ename ename, empno, mgr
2 from emp
3 START WITH MGR IS NULL
4 CONNECT BY PRIOR EMPNO = MGR
5 /
ENAME EMPNO MGR
--------------- ---------- ----------
KING 7839
JONES 7566 7839
SCOTT 7788 7566
ADAMS 7876 7788
FORD 7902 7566
SMITH 7369 7902
BLAKE 7698 7839
ALLEN 7499 7698
WARD 7521 7698
MARTIN 7654 7698
TURNER 7844 7698
JAMES 7900 7698
CLARK 7782 7839
MILLER 7934 7782
14 rows selected.
So, KING is the start with the set then JONES BLAKE and CLARK fall under him. Each of them becomes the PRIOR record in turn and their trees are expanded.
select Level, UT.USR_UDF_AGPERSONID USER_ID, UT.USR_LOGIN USER_NAME, UT.USR_DISPLAY_NAME, UT.USR_FIRST_NAME FIRST_NAME,UT.USR_LAST_NAME LAST_NAME, (select MT.USR_LOGIN from USR MT where MT.USR_key = UT.USR_MANAGER_KEY) MANAGER_NAME, UT.USR_MANAGER_KEY, UT.USR_STATUS STATUS, SYS_CONNECT_BY_PATH(UT.USR_LOGIN, '::') PATH from USR UT where level in (1, 2) and UT.USR_STATUS = 'Active' START WITH UT.USR_MANAGER_KEY=? CONNECT BY PRIOR UT.USR_KEY = UT.USR_MANAGER_KEY order siblings by UT.USR_KEY;
Saturday, May 23, 2020
IMP QUERY
---
SELECT
USR_FIRST_NAME,
USR_LAST_NAME,
USR_LOGIN,
USR_DISPLAY_NAME,
USR_EMP_TYPE,
USR_UDF_AGPERSONID,
USR_STATUS,
USR_UDF_AGEMPLOYEETYPE,
USR_UDF_AGEFFTERMINATIONDATE,
USR_UDF_AGSTATUS,
USR_UDF_AGASSIGNMENTSTARTDATE
FROM
USR
WHERE
USR_UDF_AGPERSONID = ' '
order by
USR_UDF_AGPERSONID
--- Get Request Information based on Resource history
SELECT
osi.REQUEST_KEY,
SCH.SCH_ACTUAL_START,
SCH.SCH_ACTUAL_END,
SCH.SCH_DATA,
MIL.MIL_CONDITIONAL,
orc.orc_key,
MIL.MIL_NAME,
usr.usr_login,
usr.usr_email,
sch.sch_status
from
osi,
sch,
mil,
orc,
usr,
oiu
where
orc.orc_key = osi.orc_key
and sch.sch_key = osi.sch_key
and oiu.orc_key = orc.orc_key
and oiu.usr_key = usr.usr_key
and osi.mil_key = mil.mil_key
and osi.REQUEST_KEY is not null
and osi.REQUEST_KEY = '28472' --and SCH.SCH_DATA = 'User not requested for PAN profile'
order by
sch.sch_key desc --and sch.sch_status='R'
SELECT
USR_FIRST_NAME,
USR_LAST_NAME,
USR_LOGIN,
USR_DISPLAY_NAME,
USR_EMP_TYPE,
USR_UDF_AGPERSONID,
USR_STATUS,
USR_UDF_AGEMPLOYEETYPE,
USR_UDF_AGEFFTERMINATIONDATE,
USR_UDF_AGSTATUS,
USR_UDF_AGASSIGNMENTSTARTDATE
FROM
USR
WHERE
USR_UDF_AGPERSONID = ' '
order by
USR_UDF_AGPERSONID
--- Get Request Information based on Resource history
SELECT
osi.REQUEST_KEY,
SCH.SCH_ACTUAL_START,
SCH.SCH_ACTUAL_END,
SCH.SCH_DATA,
MIL.MIL_CONDITIONAL,
orc.orc_key,
MIL.MIL_NAME,
usr.usr_login,
usr.usr_email,
sch.sch_status
from
osi,
sch,
mil,
orc,
usr,
oiu
where
orc.orc_key = osi.orc_key
and sch.sch_key = osi.sch_key
and oiu.orc_key = orc.orc_key
and oiu.usr_key = usr.usr_key
and osi.mil_key = mil.mil_key
and osi.REQUEST_KEY is not null
and osi.REQUEST_KEY = '28472' --and SCH.SCH_DATA = 'User not requested for PAN profile'
order by
sch.sch_key desc --and sch.sch_status='R'
--- Get Object infromation
select
*
from
OIU
SELECT
OBJ.OBJ_NAME,
USR_LOGIN,
OST_STATUS,
OIU_CREATE
FROM
OBJ,
OBI,
OIU,
OST,
USR
WHERE
OBJ.OBJ_KEY = OBI.OBJ_KEY
AND OBI.OBI_KEY = OIU.OBI_KEY
AND OIU.USR_KEY=USR.USR_KEY
AND OIU.OST_KEY = OST.OST_KEY
AND OST.OBJ_KEY = OBJ.OBJ_KEY
and USR_LOGIN = '<<>>'
and OBJ.OBJ_NAME= 'AD USER'
and oiu.orc_key = '179812' --AND OBJ.OBJ_NAME=' [Insert Resource Name here]'
--AND OST.OST_STATUS IN ('Enabled','Provisioned');
--Get OST Status Based on Orc key
select
OST_STATUS,
OIU_CREATE
from
OIU,
OST
where
OIU.OST_KEY = OST.OST_KEY
and oiu.orc_key = '179812'
--- adapter Information
SELECT
mil.mil_name,
MIl.Mil_kEY,
ADJ.ADJ_METHOD,
ADJ.ADJ_Constructor,
ADJ.ADJ_METHOD_DISPLAY,
adj.adj_jar_file,
ADT.ADT_NAME,
ADT.ADT_TYPE,
adp.adp_name,
adp.adp_description,
evt.evt_name,
mil.mil_name,
adv.adv_name,
adv.adv_desc,
adv.adv_data_type,
adv.adv_map_value,
adm.adm_display_value,
adm.adm_map_value,
atp.atp_in_out_flag,
atp.atp_type
from
ADJ,
ADT,
ADP,
evt,
mil --,ars
,
adV,
adm,
atp
where
ADJ.ADT_KEY = ADT.ADT_KEY
AND ADT.ADP_KEY = ADP.ADP_KEY
AND adp.evt_key = evt.evt_key
and evt.evt_key = mil.evt_key ---check process
--and adp.adp_key = ars.adP_Key
AND ADP.ADP_KEY = ADv.ADP_KEY
And ADT.ADT_KEY = atp.ADT_KEY
and atp.atp_key = adm.atp_key
And atp.atp_in_out_flag = 'Input'
and mil.mil_name in
(
<<MIL_NAME>>
)
order by
mil.mil_name
select
*
from
OIU
SELECT
OBJ.OBJ_NAME,
USR_LOGIN,
OST_STATUS,
OIU_CREATE
FROM
OBJ,
OBI,
OIU,
OST,
USR
WHERE
OBJ.OBJ_KEY = OBI.OBJ_KEY
AND OBI.OBI_KEY = OIU.OBI_KEY
AND OIU.USR_KEY=USR.USR_KEY
AND OIU.OST_KEY = OST.OST_KEY
AND OST.OBJ_KEY = OBJ.OBJ_KEY
and USR_LOGIN = '<<>>'
and OBJ.OBJ_NAME= 'AD USER'
and oiu.orc_key = '179812' --AND OBJ.OBJ_NAME=' [Insert Resource Name here]'
--AND OST.OST_STATUS IN ('Enabled','Provisioned');
--Get OST Status Based on Orc key
select
OST_STATUS,
OIU_CREATE
from
OIU,
OST
where
OIU.OST_KEY = OST.OST_KEY
and oiu.orc_key = '179812'
--- adapter Information
SELECT
mil.mil_name,
MIl.Mil_kEY,
ADJ.ADJ_METHOD,
ADJ.ADJ_Constructor,
ADJ.ADJ_METHOD_DISPLAY,
adj.adj_jar_file,
ADT.ADT_NAME,
ADT.ADT_TYPE,
adp.adp_name,
adp.adp_description,
evt.evt_name,
mil.mil_name,
adv.adv_name,
adv.adv_desc,
adv.adv_data_type,
adv.adv_map_value,
adm.adm_display_value,
adm.adm_map_value,
atp.atp_in_out_flag,
atp.atp_type
from
ADJ,
ADT,
ADP,
evt,
mil --,ars
,
adV,
adm,
atp
where
ADJ.ADT_KEY = ADT.ADT_KEY
AND ADT.ADP_KEY = ADP.ADP_KEY
AND adp.evt_key = evt.evt_key
and evt.evt_key = mil.evt_key ---check process
--and adp.adp_key = ars.adP_Key
AND ADP.ADP_KEY = ADv.ADP_KEY
And ADT.ADT_KEY = atp.ADT_KEY
and atp.atp_key = adm.atp_key
And atp.atp_in_out_flag = 'Input'
and mil.mil_name in
(
<<MIL_NAME>>
)
order by
mil.mil_name
SELECT USR.USR_LOGIN, OSI.SCH_KEY,SCH.SCH_STATUS,STA.STA_BUCKET,MIL_NAME , PKG.PKG_NAME,OBJ.OBJ_NAME,SCH.SCH_DATA,SCH.SCH_REASON FROM
OSI,SCH,STA,MIL,TOS,PKG,OIU,USR,OBJ,OST
WHERE OSI.MIL_KEY=MIL.MIL_KEY
AND SCH.SCH_KEY=OSI.SCH_KEY
AND STA.STA_STATUS=SCH.SCH_STATUS
AND TOS.PKG_KEY=PKG.PKG_KEY
AND MIL.TOS_KEY=TOS.TOS_KEY
AND OIU.USR_KEY=USR.USR_KEY
AND OIU.OST_KEY=OST.OST_KEY
AND OST.OBJ_KEY=OBJ.OBJ_KEY
AND OSI.ORC_KEY=OIU.ORC_KEY
and OIU.OIU_key = ?
and STA_BUCKET = 'Rejected'
order by SCH_KEY desc
FETCH NEXT 1 ROWS ONLY;
SELECT USR.USR_LOGIN, OSI.SCH_KEY,SCH.SCH_STATUS,STA.STA_BUCKET,MIL_NAME ,SCH.SCH_DATA,
SCH.SCH_REASON,STA_BUCKET, SCH.SCH_ACTUAL_END,SCH.SCH_ACTUAL_START FROM
OSI,SCH,STA,MIL,TOS,PKG,OIU,USR,OBJ,OST
WHERE OSI.MIL_KEY=MIL.MIL_KEY
AND SCH.SCH_KEY=OSI.SCH_KEY
AND STA.STA_STATUS=SCH.SCH_STATUS
AND TOS.PKG_KEY=PKG.PKG_KEY
AND MIL.TOS_KEY=TOS.TOS_KEY
AND OIU.USR_KEY=USR.USR_KEY
AND OIU.OST_KEY=OST.OST_KEY
AND OST.OBJ_KEY=OBJ.OBJ_KEY
AND OSI.ORC_KEY=OIU.ORC_KEY
and OIU.ORC_KEY = ?
order by SCH_KEy
# Query to check resource account status
SELECT USR.USR_LOGIN, OST.OST_STATUS, OBJ.OBJ_NAME, OIU.ORC_KEY FROM USR
INNER JOIN OIU ON USR.USR_KEY = OIU.USR_KEY
INNER JOIN OST ON OST.OST_KEY = OIU.OST_KEY
INNER JOIN OBI ON OBI.OBI_KEY = OIU.OBI_KEY
INNER JOIN OBJ ON OBI.OBJ_KEY = OBJ.OBJ_KEY
SELECT MIL.MIL_NAME,EVT.EVT_NAME,OBJ.OBJ_NAME FROM OBJ JOIN PKG ON PKG.OBJ_KEY=OBJ.OBJ_KEY JOIN TOS ON TOS.PKG_KEY=PKG.PKG_KEY JOIN MIL ON
MIL.TOS_KEY=TOS.TOS_KEY LEFT OUTER JOIN EVT ON MIL.EVT_KEY=EVT.EVT_KEY
where OBJ.OBJ_NAME = 'UNIX User'
SELECT MIL.MIL_NAME,EVT.EVT_NAME,OBJ.OBJ_NAME FROM OBJ JOIN PKG ON PKG.OBJ_KEY=OBJ.OBJ_KEY JOIN TOS ON TOS.PKG_KEY=PKG.PKG_KEY JOIN MIL ON
MIL.TOS_KEY=TOS.TOS_KEY LEFT OUTER JOIN EVT ON MIL.EVT_KEY=EVT.EVT_KEY
where OBJ.OBJ_NAME = 'UNIX User'
SELECT
mil.mil_name,MIl.Mil_kEY,
ADJ.ADJ_METHOD,ADJ.ADJ_Constructor,ADJ.ADJ_METHOD_DISPLAY,adj.adj_jar_file,
ADT.ADT_NAME,ADT.ADT_TYPE,
adp.adp_name,adp.adp_description,
evt.evt_name,
mil.mil_name
,adv.adv_name,adv.adv_desc,adv.adv_data_type,adv.adv_map_value
,adm.adm_display_value,adm.adm_map_value
,atp.atp_in_out_flag,atp.atp_type
--,ars.ars_code_name ,ars_desc
from ADJ,ADT,ADP,evt,mil,OBJ,PKG,TOS
--,ars
,adV,adm,atp
where ADJ.ADT_KEY = ADT.ADT_KEY
and OBJ.OBJ_NAME = 'UNIX User'
and PKG.OBJ_KEY=OBJ.OBJ_KEY
and TOS.PKG_KEY=PKG.PKG_KEY
and MIL.TOS_KEY=TOS.TOS_KEY
and
AND ADT.ADP_KEY = ADP.ADP_KEY
AND adp.evt_key = evt.evt_key
and evt.evt_key= mil.evt_key
---check process
--and adp.adp_key = ars.adP_Key
AND ADP.ADP_KEY = ADv.ADP_KEY
And ADT.ADT_KEY = atp.ADT_KEY
and atp.atp_key=adm.atp_key
Saturday, March 28, 2020
Installation of OIM PART1
Setting-up an Oracle Identity Manager 11gR2 PS2
environment
Contents
1. Installing a database for Identity Management suite
2.
Execute Repistory Creation Utility (RCU)
3.
Install JDK
4. Install Oracle Weblogic 10.3.6
5. Install SOA 11.1.1.7
6. Install OIM
7. Configure OIM Server and
Design Console Oracle Identity and Access Management 11gR2 PS2
8.
Configuring Weblogic for OIM
9. Configure OIM Server
and Design Console
1. Installing a database for Identity Management suite.
i.
Download Oracle Database 11 g Release 2 for Microsoft Windows from https://www.oracle.com/database/technologies/oracle-database-software-downloads.html.
i.
Download and unzip both files to the same directory ( here C drive)
ii.
Run setup.exe
iii.
If received an error, check for Oracle Hardware Minimum requirements for
database installation are met.
iv.
Click
on ‘yes’
v.
Click on next on the step Configure Security Updates
vi.
Select Create and Configure database on the installation Option step,
click on next
vii.
Select System Class
viii.
On step Typical Installation enter the details , set Global database
name as OMDB(in our case) and set administrative password. Click on Next
ix.
Prerequisite Checks are completed, click on next
x.
Review the Summary window to verify what is to be installed.
Then, click Install
xi.
The Progress window appears
xii.
Once Database installation is completed, Configuration Assistant Window
appears.
xiii.
Click OK
xiv.
Click Exit
xv.
To Test Database Installation is Completed successfully, Login to the
Database Control URL in the Configuration assistant window https://localhost:1158/em
xvi.
Enter SYSMAN as the User Name and enter the
Password, and then click Login
xvii.
The database Control Home page appers. Thus installation was successful
Tuesday, August 22, 2017
Constructors in Java
- Every class has a constructor whether it’s a normal class or a abstract class.
- Constructors are not methods and they don’t have any return type.
- Constructor name should match with class name .
- Constructor can use any access specifier, they can be declared as private also. Private constructors are possible in java but there scope is within the class only.
- Like constructors method can also have name same as class name, but still they have return type, though which we can identify them that they are methods not constructors.
- If you don’t implement any constructor within the class, compiler will do it for.
- this() and super() should be the first statement in the constructor code. If you don’t mention them, compiler does it for you accordingly.
- Constructor overloading is possible but overriding is not possible. Which means we can have overloaded constructor in our class but we can’t override a constructor.
- Constructors can not be inherited.
- If Super class doesn’t have a no-arg(default) constructor then compiler would not insert a default constructor in child class as it does in normal scenario.
- Interfaces do not have constructors.
- Abstract class can have constructor and it gets invoked when a class, which implements interface, is instantiated. (i.e. object creation of concrete class).
- A constructor can also invoke another constructor of the same class – By using this(). If you want to invoke a parameterized constructor then do it like this: this(parameter list).
Difference between Constructor and Method
- The purpose of constructor is to initialize the object of a class while the purpose of a method is to perform a task by executing java code.
- Constructors cannot be abstract, final, static and synchronised while methods can be.
- Constructors do not have return types while methods do.
source : https://beginnersbook.com/2013/03/constructors-in-java/
Wednesday, August 16, 2017
Friday, June 2, 2017
9-key-interfaces-of-Collection-framework
9 Key Interfaces of Collection framework
- Collection
- List
- Set
- SortedSet
- NavigableSet
- Queue
- Map
- SortedMap
- NavigableMap
Set Interface
.Duplicates are not allowed
Insertion order is not preserved.Child interface of the collection.
1. Set is the child interface of Collection.
2. If we want to represent a group of individual objects as a single entity, where duplicates are not allowed and insertion order is not preserved then we should go for Set.
3. Set interface doesn’t contain any new methods. So we have to use only Collection interface methods.
Implementation classes: HashSet (1.2 v) and LinkedHashSet(1.4 v)
HashSet:
1. The underlying data structure is Hashtable.
2. Duplicates are not allowed. If we are trying to insert duplicates, we won’t get any compiletime or runtime errors. add() method simply returns false.
3. Insertion order is not preserved and all objects will be inserted based n hash-code of objects.
4. Heterogeneous objects are allowed.
5. ‘null’ insertion is possible.
6. implements Serializable and Clonable interfaces but not RandomAccess.
7. HashSet is the best choice, if our frequent operation is Search operation.
1. The underlying data structure is Hashtable.
2. Duplicates are not allowed. If we are trying to insert duplicates, we won’t get any compiletime or runtime errors. add() method simply returns false.
3. Insertion order is not preserved and all objects will be inserted based n hash-code of objects.
4. Heterogeneous objects are allowed.
5. ‘null’ insertion is possible.
6. implements Serializable and Clonable interfaces but not RandomAccess.
7. HashSet is the best choice, if our frequent operation is Search operation.
SortedSet
1. It is the child interface of set.
2. If we want to represent a group of individual objects according to some sorting order and duplicates are not allowed then we should go for SortedSet
2. If we want to represent a group of individual objects according to some sorting order and duplicates are not allowed then we should go for SortedSet
Difference between List and Set?
LinkedList:
1. The underlying data structure is Double LinkedList.
2. Insertion order is preserved.
3. Duplicates are allowed.
4. Heterogeneous Objects are allowed.
5. Null insertion is possible.
6. LinkedList implements Serializable and Clonable interfaces but not RandomAccess interface.
7. LinkedList is the best choice if our frequent operation is insertion or deletion in the middle.
8. LinkedList is the worst choice if our frequent operation is retrieval operation.
9. Usually we can use LinkedList to implement stacks and queues to provide support for this requirement LinkedList class defines following specific methods.
void addFirst();
void addLast();
Object getFirst();
Object getLast();
Object removeFirst();
Object removeLast();
LinkedList Constructors:
LinkedList l1=new LinkedList();
1. creates an empty LinkedList Object. LinkedList l1=new LinkedList(Collection c);
2. Creates an equivalent LinkedList Object for the given Collection.
1. The underlying data structure is Double LinkedList.
2. Insertion order is preserved.
3. Duplicates are allowed.
4. Heterogeneous Objects are allowed.
5. Null insertion is possible.
6. LinkedList implements Serializable and Clonable interfaces but not RandomAccess interface.
7. LinkedList is the best choice if our frequent operation is insertion or deletion in the middle.
8. LinkedList is the worst choice if our frequent operation is retrieval operation.
9. Usually we can use LinkedList to implement stacks and queues to provide support for this requirement LinkedList class defines following specific methods.
void addFirst();
void addLast();
Object getFirst();
Object getLast();
Object removeFirst();
Object removeLast();
LinkedList Constructors:
LinkedList l1=new LinkedList();
1. creates an empty LinkedList Object. LinkedList l1=new LinkedList(Collection c);
2. Creates an equivalent LinkedList Object for the given Collection.
Differences between ArrayList and LinkedList
Vector class details?
1. The underlying Data structure for the vector is resizable array or growable array.
2. Duplicate objects are allowed.
3. Insertion order is preserved.
4. 'null' insertion is possible.
5. Heterogeneous objects are allowed.
6. Vector class implemented Serializable, Cloneable and RandomAccess interfaces.
7. Most of the methods present in Vector are synchronized. Hence Vector object is Thread-safe.
8. Best choice if the frequent operation is retrieval.
Vector Specific methods:
For adding objects:
1. add(Object o) [from collection – List(I)]
2. add(int index, Object o) [from List]
3. addElement(Object o) [from Vector]
4. For removing Objects:
5. Remove(Object o) [from collection]
6. removeElement(Object o) [from Vector]
7. remove(int index) [from List)
8. RemoveElementAt(int index) [from collection]
9. removeAllElements() [from Vector]
For Accessing Elements:
Object get(int index) [from Collection]
Object elementAt(int index) [from Vector]
Object firstElement() [from Vector]
Object lastElement() [from Vector]
Other Methods:
int size();
int capacity();
2. Duplicate objects are allowed.
3. Insertion order is preserved.
4. 'null' insertion is possible.
5. Heterogeneous objects are allowed.
6. Vector class implemented Serializable, Cloneable and RandomAccess interfaces.
7. Most of the methods present in Vector are synchronized. Hence Vector object is Thread-safe.
8. Best choice if the frequent operation is retrieval.
Vector Specific methods:
For adding objects:
1. add(Object o) [from collection – List(I)]
2. add(int index, Object o) [from List]
3. addElement(Object o) [from Vector]
4. For removing Objects:
5. Remove(Object o) [from collection]
6. removeElement(Object o) [from Vector]
7. remove(int index) [from List)
8. RemoveElementAt(int index) [from collection]
9. removeAllElements() [from Vector]
For Accessing Elements:
Object get(int index) [from Collection]
Object elementAt(int index) [from Vector]
Object firstElement() [from Vector]
Object lastElement() [from Vector]
Other Methods:
int size();
int capacity();
Constructors of vector class:
1. Vector v=new Vector();
Creates an empty vector object with default initial capacity 10, once vector reaches it’s max capacity a new vector object will be created with new capacity =2*current capacity.
2. Vector v=new Vector(int initialCapacity);
creates an empty Vector Object with specified initial capacity.
3. Vector v=new Vector(int initialCapacity, int incrementalCapacity);
4. Vector v=new Vector(Collection c);
Creates an equivalent Vector object for the given collection.
1. Vector v=new Vector();
Creates an empty vector object with default initial capacity 10, once vector reaches it’s max capacity a new vector object will be created with new capacity =2*current capacity.
2. Vector v=new Vector(int initialCapacity);
creates an empty Vector Object with specified initial capacity.
3. Vector v=new Vector(int initialCapacity, int incrementalCapacity);
4. Vector v=new Vector(Collection c);
Creates an equivalent Vector object for the given collection.
Stack class details (Collection Framework)?
1. It is a child class of Vector.
2. It is Specially designed class for Last in First Out order(LIFO)
Constructor of Stack:
Stack s=new Stack();
Methods in Stack:
1. Object push(Object obj);
For inserting an object to the stack.
2. Object pop():
TO removes and returns top of the stack.
3. Object peak();
To Returns the top of the stack without removal of object.
4. int search(Object obj);
if the specified object is available it returns its offset from top of the statck.
If the object is not available then it returns -1.
5. Object pop();
For inserting an object to the stack
2. It is Specially designed class for Last in First Out order(LIFO)
Constructor of Stack:
Stack s=new Stack();
Methods in Stack:
1. Object push(Object obj);
For inserting an object to the stack.
2. Object pop():
TO removes and returns top of the stack.
3. Object peak();
To Returns the top of the stack without removal of object.
4. int search(Object obj);
if the specified object is available it returns its offset from top of the statck.
If the object is not available then it returns -1.
5. Object pop();
For inserting an object to the stack
Three Cursors of Java - Enumeration
If we want to retrieve Objects one by one from the Collection, then we should go for Cursors.
There are three types of cursors are available in Java.
Enumeration
Iterator
ListIterator Enumeration:
Introduced in 1.0 version (for legacy)
We can use Enumeration to get Objects one by one from the old Collection Objects(Legacy Collection).
We can create Enumeration Object by using elements() method of Vector Class. Public Enumeration elements();
Example:
Enumeration e=v.elements();
Method of Enumeration
Enumeration defines the following two methods
1. public Boolean hasMoreElements();
2. public Object nextElement();
There are three types of cursors are available in Java.
Enumeration
Iterator
ListIterator Enumeration:
Introduced in 1.0 version (for legacy)
We can use Enumeration to get Objects one by one from the old Collection Objects(Legacy Collection).
We can create Enumeration Object by using elements() method of Vector Class. Public Enumeration elements();
Example:
Enumeration e=v.elements();
Method of Enumeration
Enumeration defines the following two methods
1. public Boolean hasMoreElements();
2. public Object nextElement();
Iterator:
1. We can apply iterator concept for any Collection object hence it is universal cursor.
2. By using iterator we can perform both read and remove operations.We can create iterator object by using iterator() method of Collection Interface
public iterator iterator();
Example:
Iterator itr=C.Iterator();
Where C is any Collection Object.
Methods In Iterator
Iterator Interface defines the following three methods
1. public Boolean hasNext()
2. public Object next()
3. public void remove()
1. We can apply iterator concept for any Collection object hence it is universal cursor.
2. By using iterator we can perform both read and remove operations.We can create iterator object by using iterator() method of Collection Interface
public iterator iterator();
Example:
Iterator itr=C.Iterator();
Where C is any Collection Object.
Methods In Iterator
Iterator Interface defines the following three methods
1. public Boolean hasNext()
2. public Object next()
3. public void remove()
Limitations of Iterator:
1. By using Enumeration and Iterator we can move only towards forward direction and we can’t move to the backward direction, and hence these are single direction cursors.
2. By using Iterator we can perform only read and remove operatiions and we can’t perform replacement of new Objects.
Note: To overcome above limitations of Iterator we should go for ListIterator
ListIterator:
1. By using ListIterator we can move either to the forward direction or to the backward direction, and hence ListIterator is bidirectional cursor
2. By using ListIterator we can perform replacement and addition of new Objects in addition to read and remove operations.
3. We can create ListIterator Object by using listIterator() method of List Interface. public ListIterator listIterator()
Example:
ListIterator itr=l.listIterator();
Where l is any List Object.
1. By using ListIterator we can move either to the forward direction or to the backward direction, and hence ListIterator is bidirectional cursor
2. By using ListIterator we can perform replacement and addition of new Objects in addition to read and remove operations.
3. We can create ListIterator Object by using listIterator() method of List Interface. public ListIterator listIterator()
Example:
ListIterator itr=l.listIterator();
Where l is any List Object.
Note: ListIterator is the most powerful cursor but its limitation is, it is applicable only for List implemented class objects and it is not a universal cursor.
Note: LinkedHashSet is the best choice to develop cache based applications, where duplicates are not allowed and insertion order must be preserved.
TreeSet
1. The underlying data structure for TreeSet Is Balanced Tree
2. Duplicate objects are allowed.
3. Insertion order not preserved, but all objects will be inserted according to some sorting order.
4. Heterogeneous objects are not allowed. If we are trying to insert heterogeneous objects then we will get runtime exception saying ClassCastException.
5. Null Insertion is allowed, but only once.
1. The underlying data structure for TreeSet Is Balanced Tree
2. Duplicate objects are allowed.
3. Insertion order not preserved, but all objects will be inserted according to some sorting order.
4. Heterogeneous objects are not allowed. If we are trying to insert heterogeneous objects then we will get runtime exception saying ClassCastException.
5. Null Insertion is allowed, but only once.
Null Acceptance:
1. For Empty TreeSet as the first element null insertion is possible. But After inserting that null if we are trying to insert any another element we will get NullPointerException.
2. For Non empty TreeSet if we are trying to insert Null then we will get NullPointerException.
Subscribe to:
Comments (Atom)
































