How to declare class for library like function
Hey guys I want to declare class Math and define method subtrction so that i can use it in other class like
package p1
public class Math
Math( ){}
int Subtration ( int a, int b)
return (a-b)
package p2
import p1.*;
Public Class Test
Test()
int somenumber=Math.Subtration(3,4);
For some reason I cannot see any methods inside Math class. when i type
somenumber = Math. it show me only one option and that is 'class' instead of mathods inside Math. any thoughts?
thx
Yes I am aware of Math class in java. The question is
how do i declare a class and call it's method in some
other class with out declaring an object of that
class.
Like I can just call Math.sqrt(4) with out
specifically declaring Math as an object. I want to
declare my own class which has some methods I wish to
call in some other class.MyClass.someMethod(). Just make sure that the methos is actually declared static. I suggest looking up the static keyword to find out what it means.
Similar Messages
-
How to declare synonym for a package function with a DBLink
Hi,
I have a PL/SQL package 'pkg'
and a function in the package 'func'
at another db using a dblink.
How to I create the correct syntax to create the synonym for this package and function.
create synonym --- for ---@dblink
Thanks.CREATE SYNONYM <name> FOR <OWNER>.<OBJECT>@<DB_LINK>
{code}
the object in this case would be pkg.func
Edited by: Tyson Jouglet on Sep 25, 2008 5:12 PM -
How to declare class variable with generic parameters?
I've got a class that declares a type parameter T. I know how to declare a static method, but this doesn't work for a static variable:
public class Test< T >
* Map of String to instances of T.
* error: '(' expected (pointing to =)
* <identifier> expected (pointing to () )
private final static < T > Map< String, T > MAP = new HashMap< String, T >();
* Get instance of type T associated with the given key.
public final static < T > T getType( String key )
return MAP.get( key );
}Edited by: 845859 on Mar 20, 2011 11:46 AMjveritas wrote:
I'm trying to create a generic polymorphic Factory class that contains boilerplate code.
I don't want to have to rewrite the registration code every time I have a different return type and parameter.I haven't seen a case yet where that is reasonable.
If you have hundreds of factories then something is wrong with your code, design and architecture.
If you have a factory which requires large number of a varying input types (producing different types) then something is probably wrong with your code and design.
A reasonable factory usage is one where you have say 20 classes to be created and you need to add a new class every 3 months. Along with additional functionality represented by the class itself and perhaps variances in usage. Thus adding about 3 lines of code to one class is trivial. Conversely if you have hundreds of classes to be created by the factory and you are adding them daily then it is likely that
1. Something is wrong with the architecture which requires a new class every day.
2. You should be using a dynamic mechanism for creation rather than static because you can't roll out a static update that often.
More than that the idiom that leads to factory creation is different for each factory. A factory that creates a database connection is substantially different than the one used in dynamic rules logic processing. A generic version will not be suitable for both.
Actualy the only case I know of where such a factory might be seem to be a 'good' idea is where someone has gotten it into their head that every class should be represented by an interface and every class created by a factory (its own factory.) And of course that is flawed. -
I'm trying to find the class for a given object. In Java, I
could do something like:
myObject.getClass().getName();
but I can't find the equivalent in Flex. How do I find the
class for a given Flex object? I don't know what it might be (other
than Object), so I don't want to do trial-and-error with "is" or
"instanceof."
Thanks!Object introspection can be done through the "describeType"
function. -
Simple java class for SQL like table?
Dear Experts,
I'm hoping that the java people here at the Oracle forums will be able to help me.
I've worked with Oracle and SQL since the 90s.
Lately, I'm learning java and doing a little project in my spare time.
It's stand alone on the desktop.
The program does not connect to any database
(and a database is not an option).
Currently, I'm working on a module for AI and decision making.
I like the idea of a table in memory.
Table/data structure with Row and columns.
And the functionality of:
Select, insert, update, delete.
I've been looking at the AbstractTableModel.
Some of the best examples I've found online (they actually compile and work) are:
http://www.java2s.com/Code/Java/Swing-JFC/extendsAbstractTableModeltocreatecustommodel.htm
http://tutiez.com/simple-jtable-example-using-abstracttablemodel.html
Although they are rather confusing.
In all the examples I find, there always seems to be
at least three layers of objects:
Data object (full of get/set methods)
AbstractTableModel
GUI (JFrame, JTable) (GUI aspect I don't need or want)
In all the cases I've seen online, I have yet to see an example
that has the equivalent of Delete or Insert.
Just like in SQL, I want to define a table with columns.
Insert some rows. Update. Select. Delete.
Question:
Is there a better java class to work with?
Better, in terms of simpler.
And, being able to do all the basic SQL like functions.
Thanks a lot!Hi Timo,
Thanks. yes I had gone thru the java doc already and they have mentioned to use java.sql.Struct, but the code which got generated calls constructor of oracle.jpub.runtime.MutableStruct where it expects oracle.sql.STRUCT and not the java.sql.STRUCT and no other constructor available to call the new implementation and that is the reason i sought for some clues.
protected ORAData create(CmnAxnRecT o, Datum d, int sqlType) throws SQLException
if (d == null) return null;
if (o == null) o = new CmnAxnRecT();
o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
return o;
here CmnAxnRecT is the class name of the generated java class for sqlType.
Thanks again. Please let me know if you have any more clues.
Regards,
Vinothgan AS -
How can I "search" for Library Items?
I am developing a site in flash and have over 800 Library Items. My problem is, I need to edit a portion of a Library Item and cannot find the Library Item, and NO, I did not delete the Library Item because when I go to preview or test the flash document, the Library Item is there in the movie. Is there any way to search for the Library Item? I am using Flash Professional 8..
Thank you.I'm not sure how you would search for it if you don't know how to identify it. You should be able to doubleclick on the object on the stage to open it up for editing. When you do that, the stage area will display the library name of the object at the top of the stage border in a tab. Things are ordered alphabetically in the library, so if you know the library name of the object you should be able to narrow down where it is.
-
How to use class for Translate..codepage/numer format
In the Unicode context, TRANSLATE... CODEPAGE/NUMBER FORMAT is not allowed.
this is the class to be used for Translate Codepage/number format.statement
Unicode Error : In the Unicode context, TRANSLATE... CODEPAGE/NUMBER FORMAT is not allowed.
Before Unicode
TRANSLATE T143T-TBTXT FROM CODE PAGE '1100' TO CODE PAGE '1105'.
After Unicode
Use class for Translate codepage to codepage.
Data : g_codepage LIKE tcp0c-charco VALUE '1100'.
CONSTANTS: c_unicodecp(4) VALUE '1105'.
PERFORM translate_codepage USING g_codepage
c_unicodecp
CHANGING T143T.
FORM translate_codepage USING P_G_CODEPAGE
P_C_UNICODECP
CHANGING P_T143T.
DATA: converter TYPE REF TO cl_abap_conv_obj.
DATA: l_out TYPE string.
DATA: l_fromcode TYPE cpcodepage.
DATA: l_tocode TYPE cpcodepage.
l_fromcode = P_G_CODEPAGE.
l_tocode = P_C_UNICODECP.
CREATE OBJECT converter
EXPORTING
incode = l_fromcode
miss = '.'
broken = '.'
use_f1 = 'X'
outcode = l_tocode
EXCEPTIONS
invalid_codepage = 1
internal_error = 2.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
WHEN 2.
MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
ENDCASE.
ENDIF.
CALL METHOD converter->convert
EXPORTING
inbuff = P_T143T
inbufflg = 0
outbufflg = 0
IMPORTING
outbuff = l_out
EXCEPTIONS
internal_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
WHEN 2.
MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
ENDCASE.
ENDIF.
P_T143T = l_out.
ENDFORM. " translate_codepage -
How to grant privilege for a specific function?
Hello all,
I wonder if exists a privilege, that i could grant to a user, just to run a specific function.
I searched in dba_sys_privs something about it but, returned nothing.
13:38:10 brunos@fastora1> select * from dba_sys_privs where privilege like '%FUNCTION%';
GRANTEE PRIVILEGE ADMIN_OPTION
Do you guys have any idea for my issue ?
Thanks in advance.BSalesRashid wrote:
Hello all,
I wonder if exists a privilege, that i could grant to a user, just to run a specific function.
I searched in dba_sys_privs something about it but, returned nothing.
13:38:10 brunos@fastora1> select * from dba_sys_privs where privilege like '%FUNCTION%';
GRANTEE PRIVILEGE ADMIN_OPTION
Do you guys have any idea for my issue ?
Thanks in advance.GRANT EXECUTE ON SPECIFIC_FUNCTION TO NEWBIE_USER; -
How to declare variable for Table type in the ABAP Editor
Hi!
I have Table Type 'FIELDNAME_TAB' (Table of fieldnames). I want to pass the list of fieldnames to this Table Type in the ABAP Editor.
Can anyone help me in this?You would declare the internal table like so.
data: itab type FIELDNAME_TAB.
data: wa like line of itab.
wa = 'This_value'.
append wa to itab.
Regards.
Rich Heilman
Message was edited by:
Rich Heilman -
How to use variable in the LIKE function along with % operators
Hi,
Is there any way i can use the variable in the Like function. That means i have query like
SELECT * FROM Device WHERE DeviceName LIKE %v_MediaName%;
Here "v_MediaName" is the userdefined variable which contains string. I want to retrieve all the records from the "DEVICE" table whose DeviceName LIKE %v_MediaName%;
If i put it in a single quotes '%v_MediaName%' then the v_MediaName will be treaded as a string instead of a variable. I am using this query in a Procedure.
please help me out to resolve the issue.
thanksLIKE '%'||v_MediaName||'%';
Will not make use of the indexes though.
Message was edited by:
satishkandi -
How to declare name for delivered pdf-attachment (e-mail)
hi,
if I'm using the XMLP Enterprise Edition, is there any chance of influencing the naming of the delivered attachments, that are sent via e-mail? On my outlook-account, I'm receiving a "att001.pdf" file .. on another e-mail client I'm receiving a "xxx.dat" file ... how can I declare the name for the file? is there an entry in xdodelivery.cfg or something like that?
hopefully someone can help meHi,
use this property for deliveryrequest
then ur attachment filename will be displayed as u specified
delReq.addProperty(DeliveryPropertyDefinitions.SMTP_CONTENT_FILENAME, repTitle+rRequestID+".pdf");
Thanks&Regards
MadhuSudhan.M -
How to organize classes for distribution...
hi have written a program that i would like to distribute for free. i have many user defined classes but i also used the Java Mail Framework and i know that not all users will have that installed on their computer so i must ship all the classes that are part of the Java Mail Framework. actually, i would like to package all the user defined classes in a jar and ship the jar files associated w/ Java Mail (mail.jar, activation.jar). any ideas on how to do this? i guess i'm not sure how the separate jar files can communicate? if what i am doing is not a good idea, what is the best way to include Java Mail w/ my program for others to use. i am lost, any help will be much appreciated. Thank you very much!
If it's a desktop app, put them all in a JAR file, add CLASSPATH to the manifest, and make it executable.
If it's a Web app, put them all in a WAR file.
If it's an enterprise app, put them all in an EAR file.
MOD -
HOW TO GENERATE IDOC FOR CHECK LIKE RFFOEDI1
Hi Gurus,
I need a big help in this. This program RFFOEDI1 do payment summary (report) and generates IDocs and RFFOUS_C does the same for Check except generating and IDoc. Is there a way to or a program to that can do this for check i.e do payment summary (report) and generates IDoc. I was told i can create a new function module to do this but I dont know how to go about doing this.
A big help will be seriously appreciated and rewarded.
Thanks for your time.Hi Subramanian,
Thanks for the quick reply. Both the program produce the summary, but only the RFFOEDI1 generates IDoc for payment (wire & ACH) exept checks. RFFOUS_C also does the same thing except that it doesn't generate the IDocs for checks.
So what I'm trying to do is have a program that will work like RFFOEDI1 for checks i.e it will also generates IDocs for checks too.
To be more clear, when the payment run program FII0 is ran, its gives a report of the payment and generates IDocs using the first program when its wire or ACH but when its checks, it uses the second program which doesn't generate checks.
I was think if we can make a function module that will generates checks and call it in the RFFOUS_C. This is just a guess and i dont know if it will work.
Please advice the best way to go about this and how.
Thanks very much. -
WLS 9.1 - How to declare datasource for web service?
If the code for a web service is generated (either a web application or ejb endpoint), how do I make sure the datasource mapping gets added to the appropriate descriptor file?
I would like to avoid having to do this manually after running the web service compiler. Can anyone help me with this?
Regards,
JoshuaJames,
Which version of Eclipse are you using? Do you have Oracle Enterprise Pack for Eclipse installed? Which version?
According to the docs, OEPE 11.1.1.6 (the latest of this post) supports WLS back to version 9.2.
http://download.oracle.com/docs/cd/E15315_05/help/oracle.eclipse.tools.common.doc/html/index.html
Make sure that you have a WLS 9.2 Server Runtime defined.
Window->Prefereces->Server->Runtime Environments
Add a BEA System, Inc WLS 9.2 server runtime and make sure it is pointing to the right place on your file system and try creating your Web Service project again.
If you still have issues, try the OEPE forum.
Enterprise Pack for Eclipse -
How to declare variable in table valued function
hello.
i have the following code to define a inline table valued function
but the use of cmn.ReshteId('Lf_WL') as a function in where clause is not good performance.
Alter function lf.fn_WholeLifeBn_GetForm(@ViewKind tinyint, @CurrentLocation int) returns table
as
return
select B.*
from lf.fn_LifeBN_GetForm(@ViewKind, @CurrentLocation) B
where Reshte = cmn.ReshteId('Lf_WL')
for better performance following code is good:
declare @Reshte smallint
set @Reshte = cmn.ReshteId('Lf_TS')
select B.*
from lf.fn_LifeBN_GetForm(@ViewKind, @CurrentLocation) B
where Reshte = @Reshte
but can not use it as the first code block in inline function.
please help for define a good function.What do you think about Multi-Statement Table-Valued UDFs?
create function Func(@Var int)
returns @T table(ColName int)
as
begin
insert into @T(ColName) values (@Var)
return
end
select * from Func(10)
select * from Func(20)
---or
alter function Func()
returns @T table(ColName int)
as
begin
declare @Var int
set @Var = 10
insert into @T(ColName) values (@Var)
return
end
select * from Func()
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Maybe you are looking for
-
"Indicator: GR-Based Invoice Verification" direct input Upld PO LSMW
Hi, Im using lsmw direct input method. I am uploading the PO. But the GR Based invoice verification field was not checked ON. Im trying this using USER_EXIT in enhancement MM06E005, with EXIT_SAPMM06E_017. Any body can tell me how i can check ON the
-
Music from Final Cut Pro to YouTube. Legal or Not??
Hi Guys, just a quick question. Can you legally use free music from the Final Cut Pro Software Program in your monetized YouTube videos???? Can someone please shed some light on this for me. Cheers
-
my ipod go block and i dont know how to unblock it
-
Problems with subtracting time
Not sure why this isn't working: select b.prcode, (to_char(b.adate_time, 'hh24:mi') - (to_char('15:30', 'hh24:mi'))) from bathroom b even select app.prcode, (to_char('15:30', 'hh24:mi')) from appointment app doesn't work either Also how would i store
-
Your photo library will not be readable by previous versions of iphoto after the upgrade. Some may be on the cloud but how can I save them? I haven't backed anything up and can't open iphoto to try. I/ve copied it onto my desktop but can't open that