Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:46:44+00:00 2026-06-15T01:46:44+00:00

Extract form main-Class: Client k = getClient(); Truster kg = new Truster(); boolean ok

  • 0

Extract form main-Class:

Client k = getClient();
Truster kg = new Truster();
boolean ok = false;

while (!ok) {
    System.out.print("\n name: ");
    //io: is a class for my input from Keyboard

    kg.setName(io.readString()); // <--need the input from here

    //argu_vali is my ValidationClass
    if (argu_vali.analyse(k, "mylist") == 0) {
        ok = true;
    }
}

ok = false;
while (!ok) {
    System.out.print("\n: ");
    kg.setSumme(io.readInteger());
    if (argu_vali.analyse(kg, "sum") == 0) {
        ok = true;
    }
}

k.add_credit(kg);

my class Client:

class Client{
     String name;

     @t_list_Check
     private ArrayList <truster> t_list= new ArrayList<>();
}

my class truster:

class Truster{
     String name;

     @Min(0)
     int sum;
}

my own ValidatorClass for t_list:

public class t_list_Validator implements ConstraintValidator<t_list_Check, Collection> {

    @Override
    public void initialize(t_list_Check a) {
    }

    @Override
    public boolean isValid(Collection kg_list, ConstraintValidatorContext cvc) {
        Object[] objects = kg_list.toArray();

        if (objects.length < 1) {
            return true;
        }

        String new_name = objects[objects.length-1].toString(); //<---need here the
                                                                //right input from above
        for (Object o : kg_list) {
            if (new_name.equals(o.toString())) {
                return false;
            }
        }
        return true;
    }
}

My problem is now, that I just get the right name for the first element in t_list. For the second input for my trusters (kg.setName(io.readString());) I receive from objects[objects.length-1].toString() in my ownValidator just the last element from t_list not the actual element.

For Example:

  • 1.run:
  • Input in main: test1
  • value new_name in t_list_Validator: test1

…

  • 2.run:
  • Input in main: test 2
  • value new_name in t_list_Validator: test1 // need here the actual input: “test2”
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:46:45+00:00Added an answer on June 15, 2026 at 1:46 am

    Just adding the element to an list, can solve the problem. After validation delete it from list an go on with validation….

    while (!ok) {
        System.out.print("\n name: ");
    
    
        kg.setName(io.readString()); 
    
        k.add(kg); // add here the element
    
        if (argu_vali.analyse(k, "mylist") == 0) {
            ok = true;
    
        }
        k.remove(k.getList().size()-1); //delete the element and go on with validation
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to extract all the <input > tags out of a <form>
I want to extract a user name and password pair and its corresponding form
I am new to Scrapy, I had the spider code class Example_spider(BaseSpider): name =
I need to extract pure text form a random web page at runtime, on
Have a simple form (only extract fields here) but for some reason the JQserilization
I'm trying to extract all input elements from a form. When I parse the
I want to extract the file name 13572_BranchInformationReport_2012-06-28.zip from the following text - 1:30,/icons/def13572_BranchInformationReport_2012-06-28.zip,13572_BranchInformationReport_2012-06-28.zip,0,184296,Jun
I have a feature whereby a class in a dll displays a form asking
import java.io.*; import java.util.*; public class Sort { public static void main(String[] args) throws
I have a bunch of name/email fields in my form like this: data[Friend][0][name] data[Friend][1][name]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.