Apache email validator: import and usage problem

2024-01-15 Thread Zulfi Khan
Hi,
I am trying to use the Apache email validator code.
 
I tried to use two import statements to import the apache email validator for 
testingemail addresses but they are not working:



import org.apache.commons.validator.routines.EmailValidator;
https://stackoverflow.com/questions/624581/what-is-the-best-java-email-address-validation-method

and 

importorg.apache.commons.validator.routines.InetAddressValidator;

https://github.com/apache/commons-validator/blob/master/src/main/java/org/apache/commons/validator/EmailValidator.java







packagecom.mycompany.validatename;

//importorg.apache.commons.validator.*; ERROR, How to correct?

//importorg.apache.commons.validator.routines.InetAddressValidator; ERROR,how 
to coorect?

importjava.util.regex.Matcher;

importjava.util.regex.Pattern;

importjavax.swing.JOptionPane;




public classValidateNameForm extends javax.swing.JFrame {




 publicValidateNameForm() {

 initComponents();

 }

 

 private voidjTF1ActionPerformed(java.awt.event.ActionEvent evt) { 

 // TODO addyour handling code here:

 } 

 private voidCheckIfInputValid(String input, String regex){

 String s;

 Patternpattern = Pattern.compile(regex);

 s =input.trim();

 Matchermatcher = pattern.matcher(s);

 JOptionPane.showMessageDialog(null, "Input "+s+" isvalid " + 

 String.valueOf(matcher.matches())); 

 }

 private voidjButton1ActionPerformed(java.awt.event.ActionEvent evt) { 

 StringemailAddress= jTF1.getText();

 booleanisValidEmail 
=EmailValidator.getInstance().isValid(emailAddress);//SYNTAX ERROR

 

 } 




 public staticvoid main(String args[]) {

 try {

 for(javax.swing.UIManager.LookAndFeelInfo info : 

 javax.swing.UIManager.getInstalledLookAndFeels()) {

 if("Nimbus".equals(info.getName())) {

 javax.swing.UIManager.setLookAndFeel(info.getClassName());

 break;

 }

 }

 } catch(ClassNotFoundException ex) {

 :

 :

 }




 // Variablesdeclaration - do not modify 

 privatejavax.swing.JButton jButton1;

 privatejavax.swing.JLabel jLabel1;

 privatejavax.swing.JTextField jTF1;

 // End ofvariables declaration 

}




Please guide me whatis the correct import statement for email validator ? I 
have show twowrong import statements, please tell me the correct ones.




What is the correctsyntax of :




boolean isValidEmail= EmailValidator.getInstance().isValid(emailAddress);




Somebody, pleaseguide me.




Zulfi.









After the last update

2024-01-15 Thread Arbol One

I am working on an application using NB-20,
PG-psql (16.1 (Debian 16.1-1.pgdg120+1), server 15.5 (Debian 
15.5-1.pgdg120+1)),

postgresql-42.7.0.jar.
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb12u1, mixed mode, 
sharing)

and, yes... Debian 12.

For some reason NB is not longer able to interact with PG since the last 
PG package update from Debian.

Is anyone else experiencing the same problem, or is it just me; I wonder.

The question is, how can I tackle this issue.

Thanks in advance.

--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing 
free services to charitable organizations.

ArbolOne on Java Development is in progress [ í ]



--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free 
services to charitable organizations.
ArbolOne on Java Development is in progress [ í ]


Re: Error highlighting for editor in NetBeans RCP application

2024-01-15 Thread Peter Kirkham

Update.

Turns out that when I previous tried enabling every single module in the 
the 'ide' and 'platform' I hadn't done a clean a build. When tried again 
and did this, the error highlighting worked. After some laborious trial 
and error I found that the module I needed to have enabled was the 
'Project UI' module in 'ide'. I didn't have this enabled in my platform 
application as I was just loading a file. I'll need the Project UI 
eventually, so it's not a drama.


Peter

On 14/01/2024 10:45 pm, Peter Kirkham wrote:


Hello there,

I've not had to reach out to the NetBeans community for a while, 
although I've been using NetBeans and the RCP for many years.


Most of the work I've done has involved embedding different 
Swing-based JPanels in TopComponents and just leveraging the 
platform's windowing system etc. Recently I started to develop an 
editor for a custom language, which is the first time I've done this. 
I've been following the tutorials, and learning a lot about lexing and 
parsing etc. Along the way I've run into a few speed bumps, but I've 
been able to resolve everything by reading the copious documentation 
on the platform or, on occasion, delving into the source on GitHub to 
see how a particular issue was been resolved in the IDE itself.


There is one issue I cannot seem to find an answer for.

*The BACKGROUND*

This relates to error highlighting. As per the error highlighting 
tutorial 
(https://netbeans.apache.org/tutorial/main/tutorials/nbm-javacc-parser/#_implementing_a_new_feature_error_parsing) 
I've create an error highlighting task that extends ParserResultTask 
and implemented a factory that extends TaskFactory:


public class EclSyntaxErrorHighlightingTask extends 
ParserResultTask {

     @Override
     public void run(EclParserResult result, SchedulerEvent event) {
     LOG.log(Level.INFO, "Running EclSyntaxErrorHighlightingTask: {0}", new 
Object[]{event.toString()});
     try {
[ omitted ...]
     } catch (BadLocationException | 
org.netbeans.modules.parsing.spi.ParseException ex) {
     Exceptions.printStackTrace(ex);
     }
     }

     @Override
     public int getPriority() {
     return 100;
     }

     @Override
     public Class getSchedulerClass() {
     return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER;
     }

     @Override
     public void cancel() {
     }
}

and

@MimeRegistration(mimeType = "text/x-eclipse", service = TaskFactory.class)
public class EclSyntaxErrorHighlightingTaskFactory extends TaskFactory {

     @Override
     public Collection create(Snapshot snapshot) {
     EclSyntaxErrorHighlightingTask task = new 
EclSyntaxErrorHighlightingTask();
     LOG.log(Level.INFO, "Created EclSyntaxErrorHighlightingTask from {0}", 
new Object[]{snapshot.toString()});
     return Collections.singleton(task);
     }
}

Note I've added a couple of logging events so I can see when the 
factory is called and creates the highlighting task, and also see when 
the task is run. For the eagle-eyed, yes the language is called the 
eclipse language, but it is nothing to do with that other IDE. It's a 
reservoir simulation language in the oil and gas industry that dates 
back to the 1980s...


*The ISSUE*

When I run the custom language model as a module within the IDE 
(right-click the module and Run), everything works a charm. Opening a 
file generates the following in the log:


INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTaskFactory]: 
Created EclSyntaxErrorHighlightingTask from Snapshot 1894046798: 
ECLIPSE_Test_Deck.ecl
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 
1007833880(source: CurrentDocumentScheduler)
INFO 
[au.com.newwavegeo.eclipse.editor.EclSyntaxErrorHighlightingTask]: 
Running EclSyntaxErrorHighlightingTask: SchedulerEvent 
210858918(source: CurrentDocumentScheduler)


So the task is being created and added to the Scheduler, and is being run.

Now, rather than running as a standalone module, what I really want to 
do is to put the module into my platform suite. Adding the module into 
the platform suite and then running the application works for 
everything except the error highlighting. So far I've done syntax 
highlighting, code completion, code reformatting, code folding, match 
occurrences. It's all working. But the error highlighting stubbornly 
does nothing. Not even having the decency to throw an exception...


When opening my custom language file, the log now shows:

22:09:48 [EclSyntaxErrorHighlightingTaskFactory|INFO]: Created 
EclSyntaxErrorHighlightingTask from Snapshot 1437838154: 
ECLIPSE_Test_Deck.ecl


So it appears that the highlighting task gets created, but it just 
isn't being run. Ever.


*Attempts to RESOLVE*

In my