Allow only String to List
Hello,
I have a ArrayList.
ArrayList as = new ArrayList();Now i want to allow only string to be added in this arraylist how can i achieve this? Don't want to use generic.
Please guide.
Ankur Raiyani wrote:
i have been asked to do not use generic.
In given example where you have seen generics. It is clearly said if you don't want to use generics then use instanceof keyword.
I want such a way that List only allows me to add String if i add other object then it should throw an error.Exactly , i've gave an idea how to use instanceof and allow only string objects in arraylist.
If not clear, please go through the below program:
import java.util.*;
import java.lang.*;
class ArrayListForOnlyString
public static void main(String st[])
List stringArrayList = new ArrayList(){
public ArrayList ar = new ArrayList();
public boolean add(Object ob) throws UnsupportedOperationException
if(ob instanceof String)
ar.add(ob);
return true;
else
throw new UnsupportedOperationException("Only String Object are accepted");
public void add(int index, Object ob)
if(ob instanceof String)
ar.add(index,ob);
else
throw new UnsupportedOperationException("Only String Object are accepted");
public Object[] toArray()
return ar.toArray();
public String toString()
return ar.toString();
try
stringArrayList.add(new String("10"));
stringArrayList.add(1,new String("10"));
// Uncomment the below line and run, it 'll give error , as you are trying to add Integer Object to array list.
//stringArrayList.add(new Integer("10"));
System.out.println("The objects of arrayList are : "+stringArrayList);
}catch(Exception e)
e.printStackTrace();
}Edited by: 833545 on Aug 31, 2011 3:53 PM
Similar Messages
-
Allowing only a list of mac addresses to connect to the internet?
Hi,
I'm setting up a solution, where access to wireless internet is granted only to a list of mac addresses. It seems MAB security is what I am after. However, before mac address is allowed internet access, I want a user to go through an external and controller-independable registration page.
Consider this flow:
Clientconnects to WLAN, since it's mac address is not allowed, the user is redirected to an external website (http://registration.com, aspx website). Here I ask the user to register an account. Using ip address from the request, I send a CLI command to the WLC controller and learn client's mac address from arp table. Here I need to run another CLI command to add the mac address to the mac database, and inform the user they can access the web.
Few struggles that I'm having now:
1) How to setup web MAB authentication, that, upon failure, redirects the user to an external website?
2) How can I add (white-list?) a mac address to enable it access to the internet?It seems I should be able to do this, can anyone elaborate?
1) Layer-2 set to Mac filtering only
2) Upon success - user is granted access
3) Upon failure, falls back to Extrenal Web Auth, which redirects the user to my custom web page
4) Upon registering, I make a postback to the action_url
5) User is authenticated? Is there a way to reset authentication sequence at step 4? I don't really want to register the user. During step 4, I'm sending user's mac address back to WLC via SSH. Since mac address will be present on the WLC after step 4, I would like it to just grant access to the mac address, rather than register the user. -
We set up a SP 2010 site with several document libraries. Library A works fine only when I click on column default value settings I get the following error message:
"configuring column based defaults is only allowed in document library lists"
This list is a normal document library and all other settings work fine. If I create a new document library or go to the settings of document library B I don't see this problem and the feature works fine.
How can I solve this problem within this library since I cannot delete the library and replace it by a new one.
Thanks.
library settings page of this library:Hi,
According to your post, my understanding is that
when you clicked on column default value settings you got the error message.
What are the column types in the library?
It seems that some column types don't support default value settings.
I recommend to create a new library with the same columns to check whether you can set
default values.
If so and the error message persists, please check the SharePoint ULS log to find more information about this error, the ULS log file is in the location: C:\Program Files\Common Files\Microsoft
Shared\Web Server Extensions\14\LOGS
You can check the ULS log by the methods here:
http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
How to allow only part of users in AD login sharepoint?
We have a SP2013 farm using windows authentication. On the AD there are 10,000 user accounts and we have no edit permission on AD. (Hence, I cannot setup any group there) As the Sharepoint admin I only have a list of 1,000 users allowed to access. There
is no existing group setup to indicate these 1,000 users.
My question is, how can I allow these 1,000 user login Sharepoint while blocking the other 9,000?
My concern is these 9,000 users will get their My Site self-created when he browse the My Site web application. Another concern is when they access some page without authorization, they will get a form allow them asking for access. The site owner may grant
access to them by mistake which I need to avoid.
Thanks.Hello Mark,
Regarding the second part of your question. You can uncheck the option 'Allow requests for Access', it is described how in the following thread:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d1e948cf-6289-48f9-9f25-81b57b292c40/how-to-hide-request-access
- Dennis | Netherlands | Blog |
Twitter -
ADF and MSSQL 2005 problems - FOR UPDATE clause allowed only for DECLARE C
Hi all.
I have a legacy application which uses MS SQL server 2000 / 2005. I've started to build up a new version of this application using JDev + ADF stack.
Everything went ok until I've tried to update some data in a Form. I'm getting this error:
com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR
Can someone figure out what's wrong?
1) In a MSSQL server connection string, normally we define the 'SelectMethod' parameter to 'cursor', as follows: jdbc:sqlserver://$host$:$port$;databaseName=dbserver;SelectMethod=cursor
Since I was not able to do this through my project's 'Application Resources > Connections' screen, I could not evaluate if this is the cause
2) I'm trying to follow the steps of an Oracle tutorial (http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm#ad), of course using MS SQL server instead of Oracle, and using some master->detail tables like the example suggests (in the tutorial, I've reached the step 11, then tried to update a record, which causes the mentioned exception)
Follows the stacktrace:
<Utils><buildFacesMessage> ADF: Adding the following JSF error message: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getMoreResults(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.seekToOutParams(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getPrepStmtHandle(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelectForAltKey(BaseSQLBuilderImpl.java:707)
at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelect(BaseSQLBuilderImpl.java:546)
at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:7789)
Regards,
Luciano S. Lorencini, SCJP, SCWCDSo, I`ve created a test project and use the MSSQL flavor to create my Business Components.
After repeated all the steps, the error did not happen again.
But some strange behavior happen: I change some data and click the "Submit" button. The changed data appears ok in screen, but the changes were not committed in database!
Do I need to explicitly tell ADF to commit that changes somewhere?
Greetings,
Luciano S. Lorencini, SCJP, SCWCD -
iOS obviously allows only 10 Apps to be Chosen in The "Open in" function. How can I control which Apps ( if more than 10 are installed) can be selected?
I think that is influenced by the order in which the apps are installed on the iPad (I believe that it's the most recent 10 ?) - but as I haven't got more than 10 apps that support any document/file type I can't check.
If you want to able to edit the list, then you could try leaving feedback for Apple : http://www.apple.com/feedback/ipad.html -
Hi all,
is there any way to allowe only PPPoE comunication on ethernet port on 2960X or 2960S catalyst switches?
Thanx
BR
DavidHi Reza,
I think David's question focused on something else: can you configure an access port on a switch so that the only frame it accepts is a PPPoE frame?
In my opinion, that should be possible - the easiest way of doing that would simply be to configure a port-ACL (PACL) that drops all IP traffic whatsoever. PPPoE-encapsulated packets are not treated as IP packets by the switch, so IP PACL will not apply. So simply doing something like this should do the trick:
ip access-list standard NoIP deny any!interface FastEthernet0/1 ip access-group NoIP in
If we wanted to be very precise, we could also create a MAC ACL to further narrow down the non-IP traffic allowed through a port. PPPoE uses EtherType values 0x8863 and 0x8864. The MAC ACL would need to be carefully specified, though, to allow other Layer2 control and management plane traffic (STP, DTP, VTP, CDP, LLDP, PAgP/LACP, UDLD, LOOP...), so it could be more difficult to create properly.
I even believe that creating a VACL would be possible although the VACLs are not officially supported on 2960 Catalysts yet (still, with a very recent IOS, they can be created and used just fine).
Best regards,
Peter -
How can I see shared pc with firewall set to allow only essential services?
How can I see shared pc with firewall set to allow only essential services?
So far if I set it as above then shared does not show up? I have to set the firewall to set access to specific applications and services to get access to my windows based hard drive.
Cheers
Mike ROk I solved it myself. Not an ideal solution as I have to connect it manually each time but it will do... Unless anyone has a way to have it auto connect when I start the mac.
Cheers
Mike R -
So my I phone 4s volume has decided to pack allowing only my phone to make sounds when I have an incoming call, I can also here fine using facetime and receiving calls. YouTube, soundcloud, any of I players will no longer play sound. I've restored the phone using iTunes on my laptop and checked all the volumes are turned up and the button at the left hand Side of the phone is in the correct position.
Try inserting and re-inserting your headphones 7 or 8 times. Also try cleaning out the headphone jack in case of debris that might be interfering with the connection/disconnection.
-
Coding in the Trasformation to allow only few currency types.
HI
Can you please let me know how i can write a program which allows only few currency's to be accepted and if other then these currency exists that particular record to be deleted before loading into the PSA
I wrote a code llike this but this is only valid for ZAR
*delete SOURCE_PACKAGE where CURRENCY ne 'ZAR'.
for example if i want to allow ZAR, USD, EUR only
hwo can i code this in the Start Rotine in the TRansformations.
please let me know
regards
Krishna Mohan.Hi Krishna,
You can try this code :
data: s_cur type c length 3.
data : i_rng_cur like range of s_cur.
data : rng_cur like line of i_rng_cur.
rng_cur-sign = 'I'.
rng_cur-option ='EQ'.
rng_cur-low = 'ZAR '.
append rng_cur to i_rng_cur.
rng_cur-low = 'USD '.
append rng_cur to i_rng_cur.
rng_cur-low = 'EUR '.
append rng_cur to i_rng_cur.
delete source_package where CURRENCY not in i_rng_cur .
This code will delete all currency other than ZAR ,EUR ,USD.You can append more values if you want .
Regards,
Jaya Tiwari -
Transfer on last day allowed only in closed fiscal year
Hi Guru,
Client kept asset transfer date as 31/10/2010 first, uploaded some asset on this date, due to some reason asset uploading was not completed for all the asset. so all the asset value which was uploaded on 31/10/2010 was done as zero.
Client took decision to upload all the asset on last day of FY 10-11 i.e 31-03-2011. transfer date was changed as 31-03.2011 and moved up to quality, unfortunatly rquest was not moved to PRD and while uploading to PRD again 25 asset got uploade by transfer date as 31/10/2010, when realized transport req of change transfer date is moved to PRD and abt 50000 asset of total 70000 asset got uploaded.F.Y 2010 was closed while uploading this assets
Year 2010 was again open for posting of cj88 transaction.
When we are uploading balance assets in the system getting error message Transfer on last day allowed only in closed fiscal year
When tried to close FY 2010, system is giving message ' Depreciation not posted completly' for 25 assets.
i tried to do value as zero for these asset through as92 but system agiain giving message Transfer on last day allowed only in closed fiscal year
so situation is we are not able to close FY 2010 and thus assets are not getting uploaded. if we run depreciation for said 25 assets for year 2010 it is not proper because actual transfer date is 31.03.2011
Please Help
Regards,
Shekharhi,
go to customizing and under asset data transfer - parameters for data transfer - date specifications - specify transfer date/last closed FY--- you need to place the last day of the period where you have last run depreciation for the legacy system and make sure that I am assuming at this stage will be the previous period or this period.
rgds,
jay -
Error In MIRO GL account allows only output tax
Hello All,
We are facing an error in MIRO that GL account xxxxx allows only out put tax. The scinario & settings are as below.
FB60
There is no error when using the particular tax code sytem posts the document
MIRO
Same vendor & tax code used as in FB60
The systemshows an error that GL ***** allows only output tax.
TAX CODE settings in FTXP
The GL showing error is in tax code
GL settings
In GL master data in control tab , the tax category is defined as out put tax
QUERY
Why in FB60 it allows the GL & not in MIRO ( Both are vendor invoice and suppose to work in similar manner)
please note in both the cases the entries are same
Vendor Cr
Expense / Stock Dr
VAT GL **** Cr
VAT GL-2 Dr
VAT GL**** is not picking @ MIRO & Picks @ FB60 with out any error
Any Idea !!!
Thanks & Regards
Arun RHi,
The problem is resolved .
The error was due to the fact that the VAT was an aquisiton tax for europe.
The details are in note 373587
Thanks for the support
Regards
Arun -
iMac 7,1. SnowLeopard. 2 printers that printed nothing, or more than ±1/4 from page top.Reinstalled OS. Time Machine BU now allows only latest (faulty) files. ±4series shown, each taking +8 hours to complete. How to reinstall from ‘DEVICES’in ‘iMac’?
You need to get rid of MacKeeper (Zeobit). Do not use their uninstaller, follow the instructions here ...
http://applehelpwriter.com/2011/09/21/how-to-uninstall-mackeeper-malware/
When that is done there does not appear to be a lot wrong if you correct the red ink entries.
The 4Gb is sufficient for Yosemite though 6 or 8 Gb would be better. You may find the download slow so be prepared. -
I have CS4 Web Premium - I am trying to look at the Adobe Cloud options for the 2015 compatible products. However...under my registered products...only Acrobat is listed...I also have the CS$ Web Premium Adobe product. When I type in the serial # from the original Adobe CS 4 dvd's package I get a "product already registered"...but I can not find it's registration on any Adobe page and it doesn't show up under registered products on the Adobe Cloud page(s)
Since it's registered...how/where do I find this verification...
Thanks TRinAz
Message was edited by: Tim Rogers - spellingYou will have to contact support by web chat to figure out any such issues.
Mylenium -
I can't log in the App store because am from Zambia which is not listed in Apple outlets. How do i go around this as apple products are used globally and not only in the listed countries. My product is a Mac book pro. i feel this limits how i can use my product
Unfortunately you have taken an Apple product outside of the area where Apple currently does business. There isn't legally a way around this. Apple cannot license apps to you where you currently live.
Maybe you are looking for
-
RAM upgrade on Satellite L300-20D
I was wondering if the laptop L300 - 20D. Can get a ram upgrade. It has 1024 MB RAM 800MHZ. And i need 1500 MB .
-
If i want to create and print address labels should i use contacts or a spreadsheet
I am new MAC user. I want to create a separate contact and address list for my Christmas card list. Should I use contacts or should I create a spreadsheet and do a mail merge? I am thinking Contacts should be easier to manage and maintain. Thanks M
-
Gnome 3.2 suspend with status menu: screen is not locked after wakeup
Locking the screen with gnome-screensaver-command --lock or with the lock screen option from the status menu works fine. However, when the suspend from the status menu is used, although it does seem to go into lock mode before it suspends (the screen
-
RoboHelp 8: Loading time of TOC in FireFox
I am using RoboHelp 8. After I generated my help and deployed it on a web server, I noticed that my TOC loads instantly in IE, just like it should. However, when I access my web help in FireFox, it takes around 2 minutes to load the TOC in FF. I am u
-
Cursor keys do not properly change to next/previous image
Since a few days, one of my two Lightroom-computers shows a permanent, quite annoying bug, regarding the curser left/right key: It happens in loupe view: When I press the cursor-right key, Lightroom doesn't change to the next image Instead, it doesn'