问:
How to extract and display the preference node from the below JSON
JSON:

```<code>[
    {
        "name": "TEST",
        "desc": "",
        "descData": null,
        "closed": false,
        "idOrganization": null,
        "idEnterprise": null,
        "limits": null,
        "pinned": null,
        "shortLink": "0vww",
        "powerUps": [],
        "dateLastActivity": "2020-02-20T17:35:34.008Z",
        "idTags": [],
        "datePluginDisable": null,
        "creationMethod": null,
        "ixUpdate": null,
        "enterpriseOwned": false,
        "idBoardSource": "1232131",
        "id": "1231231123",
        "starred": false,
        "url": "test",
        "prefs": {
            "permissionLevel": "private",
            "hideVotes": false,
            "voting": "disabled",
            "comments": "members",
            "invitations": "members",
            "selfJoin": false,
            "cardCovers": true,
            "isTemplate": false,
            "cardAging": "regular",
            "calendarFeedEnabled": false,
            "background": "5c2f9de25f4d0845100f81b3",
            "backgroundImage": "TEST",
            "backgroundTile": false,
            "backgroundBrightness": "light",
            "backgroundBottomColor": "#635e5d",
            "backgroundTopColor": "#f4f4f3",
            "canBePublic": true,
            "canBeEnterprise": true,
            "canBeOrg": true,
            "canBePrivate": true,
            "canInvite": true
        },
        "subscribed": false,
        "labelNames": {
            "green": "",
            "yellow": "",
            "orange": "",
            "red": "",
            "purple": "",
            "blue": "",
            "sky": "",
            "lime": "",
            "pink": "",
            "black": ""
        },
        "dateLastView": "2020-05-24T20:26:00.621Z",
        "shortUrl": "https://trello.com",
        "templateGallery": null,
        "premiumFeatures": []
    }
]
</code>```

The below code fails when trying to extract user preferences node-

```<code>    System.out.println("User Preferences are below: \n");
    LinkedHashMap <String,String> tmplist = new LinkedHashMap<>();
    tmplist.putAll(js.get("prefs"));
    Iterator<String> itr = tmplist.keySet().iterator();
    while (itr.hasNext())
    {
        String key = itr.next();
        System.out.println(key+""+tmplist.get(key));  // ---- Fails here. java.util.LinkedHashMap
                                                    //cannot be cast to java.lang.String
    }
</code>```

Do not want to manually extract values as below
        String colorblind = js.get("prefs.colorBlind").toString();
        System.out.println("Color Blind is "+colorblind);

Please suggest how can I fix the code such that I can extract the complete preferences.

答:
Your JSON starts with JSON Array, so when you use "get" method you will get List<> of something.
Using your code you would get List<LinkedHashMap<>>.

You shouldn't use a specific map implementation. Instead, you should use an interface so JsonPath can figure out which map implementation is the best like this:
List<Map<>>

Another thing is generic arguments in the Map<>. prefs JSON Object contains both, Strings and Booleans. Using generic arguments of Map as <String, String> you expose yourself to ClassCastException. Instead, you should use Object and figure out which type is it.

Here's the implementation of how to print out keys and values of prefs JSON Object:

Older versions of Java:

```<code>    List<Map<String, Object>> prefs = path.get("prefs");
    for (Map<String, Object> pref : prefs) {
      for (String key : pref.keySet()) {
        System.out.println(String.format("key: %s | value: %s", key, pref.get(key)));
      }
    }
</code>```

Since Java 1.8 we can use Streams

```<code>    List<Map<String, Object>> prefs = path.get("prefs");
    prefs.forEach(map -> map.forEach((key, value) -> System.out.println(String.format("key: %s | value: %s", key, value))));
</code>```

Body:
JSON:

[
    {
        "name": "TEST",
        "desc": "",
        "descData": null,
        "closed": false,
        "idOrganization": null,
        "idEnterprise": null,
        "limits": null,
        "pinned": null,
        "shortLink": "0vww",
        "powerUps": [],
        "dateLastActivity": "2020-02-20T17:35:34.008Z",
        "idTags": [],
        "datePluginDisable": null,
        "creationMethod": null,
        "ixUpdate": null,
        "enterpriseOwned": false,
        "idBoardSource": "1232131",
        "id": "1231231123",
        "starred": false,
        "url": "test",
        "prefs": {
            "permissionLevel": "private",
            "hideVotes": false,
            "voting": "disabled",
            "comments": "members",
            "invitations": "members",
            "selfJoin": false,
            "cardCovers": true,
            "isTemplate": false,
            "cardAging": "regular",
            "calendarFeedEnabled": false,
            "background": "5c2f9de25f4d0845100f81b3",
            "backgroundImage": "TEST",
            "backgroundTile": false,
            "backgroundBrightness": "light",
            "backgroundBottomColor": "#635e5d",
            "backgroundTopColor": "#f4f4f3",
            "canBePublic": true,
            "canBeEnterprise": true,
            "canBeOrg": true,
            "canBePrivate": true,
            "canInvite": true
        },
        "subscribed": false,
        "labelNames": {
            "green": "",
            "yellow": "",
            "orange": "",
            "red": "",
            "purple": "",
            "blue": "",
            "sky": "",
            "lime": "",
            "pink": "",
            "black": ""
        },
        "dateLastView": "2020-05-24T20:26:00.621Z",
        "shortUrl": "https://trello.com",
        "templateGallery": null,
        "premiumFeatures": []
    }
]

The below code fails when trying to extract user preferences node-

    System.out.println("User Preferences are below: \n");
    LinkedHashMap <String,String> tmplist = new LinkedHashMap<>();
    tmplist.putAll(js.get("prefs"));
    Iterator<String> itr = tmplist.keySet().iterator();
    while (itr.hasNext())
    {
        String key = itr.next();
        System.out.println(key+""+tmplist.get(key));  // ---- Fails here. java.util.LinkedHashMap
                                                    //cannot be cast to java.lang.String
    }

Do not want to manually extract values as below
        String colorblind = js.get("prefs.colorBlind").toString();
        System.out.println("Color Blind is "+colorblind);

Please suggest how can I fix the code such that I can extract the complete preferences.

Body:
Your JSON starts with JSON Array, so when you use "get" method you will get List<> of something.
Using your code you would get List<LinkedHashMap<>>.

You shouldn't use a specific map implementation. Instead, you should use an interface so JsonPath can figure out which map implementation is the best like this:
List<Map<>>

Another thing is generic arguments in the Map<>. prefs JSON Object contains both, Strings and Booleans. Using generic arguments of Map as <String, String> you expose yourself to ClassCastException. Instead, you should use Object and figure out which type is it.

Here's the implementation of how to print out keys and values of prefs JSON Object:

Older versions of Java:

    List<Map<String, Object>> prefs = path.get("prefs");
    for (Map<String, Object> pref : prefs) {
      for (String key : pref.keySet()) {
        System.out.println(String.format("key: %s | value: %s", key, pref.get(key)));
      }
    }

Since Java 1.8 we can use Streams

    List<Map<String, Object>> prefs = path.get("prefs");
    prefs.forEach(map -> map.forEach((key, value) -> System.out.println(String.format("key: %s | value: %s", key, value))));


来源: stackexchange

问:
Soap Client created from WSDL does not bind to all data declared in response for method, VS2017
I have been asked to create an application in VB.NET that utilizes an External web service, they provided a WSDL which creates all necessary proxy, methods and classes, however it seems since this service runs on an IBM websphere server with J2EE that something is not working as designed for .NET, when i create instance of the service and call a method that uses a specific set of parameters and returns a specific complex type, some of the data is lost in .net, the XML response from the server contains all the correct data, it just is not available as part of the data in .net to process.

I have not been involved with soap for many years now, mostly i do web development and create webservices that are called using ajax so i am having difficulty figuring this one out, hope someone can provide me some direction.

This is what is returned from their server, the element named "userArea" is supposed to be present in the object declared as a response but it is not populated inside debugger or have any value (Not serialized).

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
    <upd:pricingAndAvailabilityResponse xmlns:upd="http://shopmanagement.service.ml.imc.com" xmlns:upd1="http://shopmanagement.datatypes.ml.imc.com">
      <upd1:freightCharge>0.00</upd1:freightCharge>
      <upd1:partPriceAvailability>
        <upd1:lineItemNumber>05</upd1:lineItemNumber>
        <upd1:lineCode>A1</upd1:lineCode>
        <upd1:mfgPartNumber>19-B7135NM</upd1:mfgPartNumber>
        <upd1:orderedAsNumber>19-B7135NM</upd1:orderedAsNumber>
        <upd1:qtyRequested>1</upd1:qtyRequested>
        <upd1:partDescription>CALIPER</upd1:partDescription>
        <upd1:brandOrManufacturer>A1 Cardone</upd1:brandOrManufacturer>
        <upd1:customerPrice>112.08</upd1:customerPrice>
        <upd1:listPrice>322.43</upd1:listPrice>
        <upd1:corePrice>69.0</upd1:corePrice>
        <upd1:timeZone>PST</upd1:timeZone>
        <upd1:flag>0</upd1:flag>
        <upd1:codeType>
          <upd1:message/>
        </upd1:codeType>
        <upd1:userArea>
          <upd1:branch>Phoenix Fillmore, AZ</upd1:branch>
          <upd1:availableQuantity>1</upd1:availableQuantity>
          <upd1:carrier>GROUND</upd1:carrier>
          <upd1:transitDays>GROUND 2 Business</upd1:transitDays>
          <upd1:freightCharge/>
        </upd1:userArea>
      </upd1:partPriceAvailability>
    </upd:pricingAndAvailabilityResponse>
  </soapenv:Body>
</soapenv:Envelope>```

Here is the sample of the method called, it returns a type of declared as pricingAndAvailabilityResponse which is in their specifications, but part of it just disappear's in the response after loaded into the application, it is however contained in the XML the WSDL is supposed to bind i just don't know at this point how to gain access to it, any thoughts would be greatly appreciated since i am running into dead ends.

sample of the method called

Data returned to the response object, items circled are not populated but should be based on the XML.

Data returned to the response object

The Webservice providers response was:

The binding of the response to the client objects entirely depend on the client program and web service engine at the client side. For your reference we tried to consume the same web service using java and you can see in the below screenshot it is able to bind userArea. If your programming environment is not able to tie up the elements, the other approach for you could be parsing the response document in a handler and read DOM elements.

Please let us know in case any element in the response is not coming as per WSDL.

And below is a test they ran using JAVA but there must be something different about JAVA I would guess.

below is a test they ran using JAVA

I ran SOAP validation as per suggestion and it came back as "Schema Compliance Failed" could this be related ? And if so how could it be corrected in VB.NET or can this only be fixed by the provider?

Schema Compliance Failed

答: In the end the solution for me was to validate the XML using SOAPUI, it identified schema issues in the WSDL and after requesting the provider to send me a correct WSDL all is normal, I am guessing that the WSDL I received was probably the incorrect one since he had reported earlier that there was no other complaints regarding the Webservice, it only surfaced as a result of my new project involvement. Ashish's suggestion sent me in the right direction.</p>

ContentLicense: CC BY-SA 4.0

Body:
I have been asked to create an application in VB.NET that utilizes an External web service, they provided a WSDL which creates all necessary proxy, methods and classes, however it seems since this service runs on an IBM websphere server with J2EE that something is not working as designed for .NET, when i create instance of the service and call a method that uses a specific set of parameters and returns a specific complex type, some of the data is lost in .net, the XML response from the server contains all the correct data, it just is not available as part of the data in .net to process.

I have not been involved with soap for many years now, mostly i do web development and create webservices that are called using ajax so i am having difficulty figuring this one out, hope someone can provide me some direction.

This is what is returned from their server, the element named "userArea" is supposed to be present in the object declared as a response but it is not populated inside debugger or have any value (Not serialized).

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
    <upd:pricingAndAvailabilityResponse xmlns:upd="http://shopmanagement.service.ml.imc.com" xmlns:upd1="http://shopmanagement.datatypes.ml.imc.com">
      <upd1:freightCharge>0.00</upd1:freightCharge>
      <upd1:partPriceAvailability>
        <upd1:lineItemNumber>05</upd1:lineItemNumber>
        <upd1:lineCode>A1</upd1:lineCode>
        <upd1:mfgPartNumber>19-B7135NM</upd1:mfgPartNumber>
        <upd1:orderedAsNumber>19-B7135NM</upd1:orderedAsNumber>
        <upd1:qtyRequested>1</upd1:qtyRequested>
        <upd1:partDescription>CALIPER</upd1:partDescription>
        <upd1:brandOrManufacturer>A1 Cardone</upd1:brandOrManufacturer>
        <upd1:customerPrice>112.08</upd1:customerPrice>
        <upd1:listPrice>322.43</upd1:listPrice>
        <upd1:corePrice>69.0</upd1:corePrice>
        <upd1:timeZone>PST</upd1:timeZone>
        <upd1:flag>0</upd1:flag>
        <upd1:codeType>
          <upd1:message/>
        </upd1:codeType>
        <upd1:userArea>
          <upd1:branch>Phoenix Fillmore, AZ</upd1:branch>
          <upd1:availableQuantity>1</upd1:availableQuantity>
          <upd1:carrier>GROUND</upd1:carrier>
          <upd1:transitDays>GROUND 2 Business</upd1:transitDays>
          <upd1:freightCharge/>
        </upd1:userArea>
      </upd1:partPriceAvailability>
    </upd:pricingAndAvailabilityResponse>
  </soapenv:Body>
</soapenv:Envelope>

Here is the sample of the method called, it returns a type of declared as pricingAndAvailabilityResponse which is in their specifications, but part of it just disappear's in the response after loaded into the application, it is however contained in the XML the WSDL is supposed to bind i just don't know at this point how to gain access to it, any thoughts would be greatly appreciated since i am running into dead ends.

sample of the method called

Data returned to the response object, items circled are not populated but should be based on the XML.

Data returned to the response object

The Webservice providers response was:

The binding of the response to the client objects entirely depend on the client program and web service engine at the client side. For your reference we tried to consume the same web service using java and you can see in the below screenshot it is able to bind userArea. If your programming environment is not able to tie up the elements, the other approach for you could be parsing the response document in a handler and read DOM elements.

Please let us know in case any element in the response is not coming as per WSDL.

And below is a test they ran using JAVA but there must be something different about JAVA I would guess.

below is a test they ran using JAVA

I ran SOAP validation as per suggestion and it came back as "Schema Compliance Failed" could this be related ? And if so how could it be corrected in VB.NET or can this only be fixed by the provider?

Schema Compliance Failed


问:
How to delete elements from a numpy array using indecies returned by scipy.spatial.KDTree.query_ball_point method
I am trying to use Kdtree data structure to remove closest points from an array preferablly without for loops.

```<code>import sys

import time

import scipy.spatial

class KDTree:
    """
    Nearest neighbor search class with KDTree
    """

    def __init__(self, data):
        # store kd-tree
        self.tree = scipy.spatial.cKDTree(data)

    def search(self, inp, k=1):
        """
        Search NN
        inp: input data, single frame or multi frame
        """

        if len(inp.shape) >= 2:  # multi input
            index = []
            dist = []

            for i in inp.T:
                idist, iindex = self.tree.query(i, k=k)
                index.append(iindex)
                dist.append(idist)

            return index, dist

        dist, index = self.tree.query(inp, k=k)
        return index, dist

    def search_in_distance(self, inp, r):
        """
        find points with in a distance r
        """

        index = self.tree.query_ball_point(inp, r)
        return np.asarray(index)

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
start = time.time()
fig, ar = plt.subplots()
t = 0
R = 50.0
u = R *np.cos(t)
v = R *np.sin(t)

x = np.linspace(-100,100,51)
y = np.linspace(-100,100,51)

xx, yy = np.meshgrid(x,y)
points =np.vstack((xx.ravel(),yy.ravel())).T
Tree = KDTree(points)
ind = Tree.search_in_distance([u, v],10.0)
ar.scatter(points[:,0],points[:,1],c='k',s=1)
infected = points[ind]
ar.scatter(infected[:,0],infected[:,1],c='r',s=5)

def animate(i):
    global R,t,start,points
    ar.clear()
    u = R *np.cos(t)
    v = R *np.sin(t)
    ind = Tree.search_in_distance([u, v],10.0)
    ar.scatter(points[:,0],points[:,1],c='k',s=1)
    infected = points[ind]
    ar.scatter(infected[:,0],infected[:,1],c='r',s=5)
    #points = np.delete(points,ind)
    t+=0.01
    end = time.time()
    if end - start != 0:
        print((end - start), end="\r")
        start = end
ani = animation.FuncAnimation(fig, animate, interval=20)
plt.show()
</code>```

but no matter what i do i can't get np.delete to work with the indecies returned by the ball_query method. What am i missing?

I would like to make the red colored points vanish in each iteration from the points array.

答:
Your points array is a Nx2 matrix. Your ind indices are a list of row indices. What you need is to specify the axis along which you need deletion, ultimately this:

```<code>points = np.delete(points,ind,axis=0)
</code>```

Also, once you delete indices, watch out for missing indices in your next iteration/calculations. Maybe you want to have a copy to delete points and plot and another copy for calculations that you do not delete from it.

Body:
I am trying to use Kdtree data structure to remove closest points from an array preferablly without for loops.

import sys

import time

import scipy.spatial

class KDTree:
    """
    Nearest neighbor search class with KDTree
    """

    def __init__(self, data):
        # store kd-tree
        self.tree = scipy.spatial.cKDTree(data)

    def search(self, inp, k=1):
        """
        Search NN
        inp: input data, single frame or multi frame
        """

        if len(inp.shape) >= 2:  # multi input
            index = []
            dist = []

            for i in inp.T:
                idist, iindex = self.tree.query(i, k=k)
                index.append(iindex)
                dist.append(idist)

            return index, dist

        dist, index = self.tree.query(inp, k=k)
        return index, dist

    def search_in_distance(self, inp, r):
        """
        find points with in a distance r
        """

        index = self.tree.query_ball_point(inp, r)
        return np.asarray(index)

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
start = time.time()
fig, ar = plt.subplots()
t = 0
R = 50.0
u = R *np.cos(t)
v = R *np.sin(t)

x = np.linspace(-100,100,51)
y = np.linspace(-100,100,51)

xx, yy = np.meshgrid(x,y)
points =np.vstack((xx.ravel(),yy.ravel())).T
Tree = KDTree(points)
ind = Tree.search_in_distance([u, v],10.0)
ar.scatter(points[:,0],points[:,1],c='k',s=1)
infected = points[ind]
ar.scatter(infected[:,0],infected[:,1],c='r',s=5)

def animate(i):
    global R,t,start,points
    ar.clear()
    u = R *np.cos(t)
    v = R *np.sin(t)
    ind = Tree.search_in_distance([u, v],10.0)
    ar.scatter(points[:,0],points[:,1],c='k',s=1)
    infected = points[ind]
    ar.scatter(infected[:,0],infected[:,1],c='r',s=5)
    #points = np.delete(points,ind)
    t+=0.01
    end = time.time()
    if end - start != 0:
        print((end - start), end="\r")
        start = end
ani = animation.FuncAnimation(fig, animate, interval=20)
plt.show()

but no matter what i do i can't get np.delete to work with the indecies returned by the ball_query method. What am i missing?

I would like to make the red colored points vanish in each iteration from the points array.

Body:
Your points array is a Nx2 matrix. Your ind indices are a list of row indices. What you need is to specify the axis along which you need deletion, ultimately this:

points = np.delete(points,ind,axis=0)

Also, once you delete indices, watch out for missing indices in your next iteration/calculations. Maybe you want to have a copy to delete points and plot and another copy for calculations that you do not delete from it.


问:
Not obtaining the correct output for the following code
I'm curious as to why the output for the following code is 14 1. When I go through the code myself, I'm ending up with counter being equal to 2, and count being equal to 4. I want to make sure that we are only printing the second index, so we only go through the loop two times, right?

```<code> package mix4;

public class Mix4 {

    int counter = 0;

    public static void main(String[] args) {
        int count = 0;
        Mix4[] m4a = new Mix4[20];
        int x = 0;
        while(x < 9) {
            m4a[x] = new Mix4();
            m4a[x].counter = m4a[x].counter + 1;
            count = count + 1;
            count = count + m4a[x].maybeNew(x);
            x = x + 1;
        }
        System.out.println(count + " " + m4a[1].counter);
    }

        public static int maybeNew(int index) {
            if (index < 5) {
                Mix4 m4 = new Mix4();
                m4.counter = m4.counter + 1;
                return 1;
            }

            return 0;

        }

    }
</code>```

答:
mayBeNew is a static method. So the following

```<code>count = count + m4a[x].maybeNew(x);
</code>```

is no different than

```<code>count = count + Mix4.maybeNew(x);
// or
count = count + maybeNew(x);
</code>```

Body:
I'm curious as to why the output for the following code is 14 1. When I go through the code myself, I'm ending up with counter being equal to 2, and count being equal to 4. I want to make sure that we are only printing the second index, so we only go through the loop two times, right?

 package mix4;

public class Mix4 {

    int counter = 0;

    public static void main(String[] args) {
        int count = 0;
        Mix4[] m4a = new Mix4[20];
        int x = 0;
        while(x < 9) {
            m4a[x] = new Mix4();
            m4a[x].counter = m4a[x].counter + 1;
            count = count + 1;
            count = count + m4a[x].maybeNew(x);
            x = x + 1;
        }
        System.out.println(count + " " + m4a[1].counter);
    }

        public static int maybeNew(int index) {
            if (index < 5) {
                Mix4 m4 = new Mix4();
                m4.counter = m4.counter + 1;
                return 1;
            }

            return 0;

        }

    }

Body:
mayBeNew is a static method. So the following

count = count + m4a[x].maybeNew(x);

is no different than

count = count + Mix4.maybeNew(x);
// or
count = count + maybeNew(x);


问:
JDK 11: java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler
We are migrating to openjdk 11 from jdk 8. Some of our projects that uses soap to call third party apis are failing with error:

```<code>java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler
</code>```

After doing some research, I tried by adding dependencies :

[
references:

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

Replacements for deprecated JPMS modules with Java EE APIs

]

```<code> <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.soap</groupId>
        <artifactId>javax.xml.soap-api</artifactId>
        <version>1.3.5</version>
    </dependency>
</code>```

Did not work. may I get an idea on the alternatives?

答:
The javax APIs were transitioned to Jakarta, so in 2020 the proper dependency is the following:

```<code><dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>2.3.3</version>
</dependency>
</code>```

Here's an article summarizing what happened:
Java Magazine - Transition from Java EE to Jakarta EE

And here's a very useful table with mappings between the old artifacts and the new one.

Body:
We are migrating to openjdk 11 from jdk 8. Some of our projects that uses soap to call third party apis are failing with error:

java.lang.NoClassDefFoundError: javax/xml/ws/handler/soap/SOAPHandler

After doing some research, I tried by adding dependencies :

[
references:

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

Replacements for deprecated JPMS modules with Java EE APIs

]

 <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.soap</groupId>
        <artifactId>javax.xml.soap-api</artifactId>
        <version>1.3.5</version>
    </dependency>

Did not work. may I get an idea on the alternatives?

Body:
The javax APIs were transitioned to Jakarta, so in 2020 the proper dependency is the following:

<dependency>
    <groupId>jakarta.xml.ws</groupId>
    <artifactId>jakarta.xml.ws-api</artifactId>
    <version>2.3.3</version>
</dependency>

Here's an article summarizing what happened:
Java Magazine - Transition from Java EE to Jakarta EE

And here's a very useful table with mappings between the old artifacts and the new one.


问:
Use whereHas and query pivot table at the same time is possible in laravel?
I have 2 entities: Beneficiaries and Initiatives, those related in a pivot table beneficiary_initiative.
I want all the beneficiaries related to a specific "region". But i have following error:

```<code>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'beneficiaries.region' in 'where clause' (SQL: select count(*) as aggregate from `initiatives` where `state` = 1 and exists (select * from `beneficiaries` inner join `beneficiary_initiative` on `beneficiaries`.`id` = `beneficiary_initiative`.`beneficiary_id` where `initiatives`.`id` = `beneficiary_initiative`.`initiative_id` and `beneficiaries`.`region` = 120000))
</code>```

Laravel version: 5.4

My database structure:

beneficiaries

id

name

initiatives

id

name

beneficiary_initiative

beneficiary_id

initiative_id

region

province

My models:

// Beneficiary.php
public function initiatives()
{
  return $this->belongsToMany(Initiative::class)->withPivot('region', 'province');
}
```

<pre class="lang-php prettyprint-override"><code>// Initiative.php

public function beneficiaries()
{
  return $this->belongsToMany(Beneficiary::class)->withPivot('region', 'province');
}

public static function search ($region)
{
  $query = Initiative::select(
    'initiatives.id',
    'initiatives.name'
  )->with('program')
   ->with('beneficiaries')
   ->with('contacts');

  $query->when($region !== null, function ($q) use ($region) {
      return $q->whereHas('beneficiaries', function ($q1) use ($region) {
        $q1->where('beneficiary_initiative.region', '=', $region);
      });
  });

  $initiatives = $query->get();
  return $initiatives;
}
</code>```

答: Your table beneficiaries does not have region field. Only beneficiary_initiative has that field. I don't know how to generate query from laravel, but you must change that filter.

Body:
I have 2 entities: Beneficiaries and Initiatives, those related in a pivot table beneficiary_initiative.
I want all the beneficiaries related to a specific "region". But i have following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'beneficiaries.region' in 'where clause' (SQL: select count(*) as aggregate from `initiatives` where `state` = 1 and exists (select * from `beneficiaries` inner join `beneficiary_initiative` on `beneficiaries`.`id` = `beneficiary_initiative`.`beneficiary_id` where `initiatives`.`id` = `beneficiary_initiative`.`initiative_id` and `beneficiaries`.`region` = 120000))

Laravel version: 5.4

My database structure:

beneficiaries

id

name

initiatives

id

name

beneficiary_initiative

beneficiary_id

initiative_id

region

province

My models:

// Beneficiary.php
public function initiatives()
{
  return $this->belongsToMany(Initiative::class)->withPivot('region', 'province');
}

// Initiative.php

public function beneficiaries()
{
  return $this->belongsToMany(Beneficiary::class)->withPivot('region', 'province');
}

public static function search ($region)
{
  $query = Initiative::select(
    'initiatives.id',
    'initiatives.name'
  )->with('program')
   ->with('beneficiaries')
   ->with('contacts');

  $query->when($region !== null, function ($q) use ($region) {
      return $q->whereHas('beneficiaries', function ($q1) use ($region) {
        $q1->where('beneficiary_initiative.region', '=', $region);
      });
  });

  $initiatives = $query->get();
  return $initiatives;
}


问:
Django: Static files are not found
I'm trying to add some static files to my project. I have tried adding a static folder to my app.

I have two apps:

Authentication (authn),

Main (main).

I have a lot of CSS/js content and I don't really know which is the best method to save the files, maybe all static files should be in one directory 'staticfiles' or each app should have 'static' folder. I have tried adding static folder to one of my apps, at this time - authn. And by trying to load the static files I firstly did python manage.py collectstatic, that put my all files into one folder, but I got two different folders now - admin, main. After tried putting all my static files into a static folder in authn app, but the static files were not loading after that. Here are my project structure and some photos and logs of the console, pycharm.

答:
You need to add authn's static to STATICFILES_DIRS. Detail</p>

```<code>STATICFILES_DIRS=[
  os.path.join(PROJECT_PATH, 'static'),
  os.path.join(PROJECT_PATH, 'authn', 'static')
]
</code>```

Title: Django: Static files are not found

Body:
You need to add authn's static to STATICFILES_DIRS. Detail

STATICFILES_DIRS=[
  os.path.join(PROJECT_PATH, 'static'),
  os.path.join(PROJECT_PATH, 'authn', 'static')
]


问:
How to inflate progressBar layout without code duplication when there is an api call
I have this flow in my app:

declare endpoints:

```<code>public interface EndPoints {
    @GET(Constants.POPULAR)
    Call<AllData> getAllData(
            @Query("api_key") String apiKey
    );
}
</code>```

Retrofit service:

```<code>  private static EndPoints endPoints = retrofit.create(EndPoints.class);

    public static EndPoints getEndpoints() {
        return  endPoints ;
    }
</code>```

And I call this inside my view model:

```<code>   private void getDataFromApi() {
    Call<AllData> call = RetrofitService.getEndPoints().getAllData(Constants.API_KEY);
    call.enqueue(new Callback<AllData>() {
        @Override
        public void onResponse(Call<AllData> call, Response<AllData> response) {

        }
            if (response.isSuccessful()) {
                _allData.setValue(response.body());
        }

        @Override
        public void onFailure(Call<AllData> call, Throwable t) {
        }
    });

}
</code>```

Base Activity:

```<code>public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
    }
</code>```

Progress bar layout(I updated this instead of using frame layout every xml file, I created xml called progress bar layout and I want to inflate this every call):

```<code><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>
</FrameLayout>
</code>```

How can I set progress bar every api call?

Initally I checked in getDataFromApi if is loading or not, set the value into bool LiveData and observed this inside my activity.

The problem with this is it's an insane amount of code duplication.

Every api call I need to set loading state, every activity I need to observer the loading state and call View.Visible and View.Hide and every activity xml I need to create frame layout with progress bar.

I believe the answer is somewhere inside the base activity as it is the only place that can "control" all the activities in the app, but I can't think of a way of solving this problem

答:
If you used status solely for purpose of showing ProgressBar then you can try changing your getDataFromApi() to take Context object as argument and then show a AlertDialog which contains a ProgressBar(modify it as you like depending on your need) and then dismiss() it in response.isSuccessful() being true.

```<code>private void getDataFromApi(Context context) {
           // status.setValue(Status.LOADING);
           // start showing progressbar instead of setting the status
           // or actually u can do both depending on the usage of the `status` variable
        MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
        ProgressBar progressBar = new ProgressBar(this);
        progressBar.setIndeterminate(true);
        builder.setView(progressBar);
        final AlertDialog dialog = builder.show();

        Call<AllData> call = RetrofitService.getEndPoints().getAllData(Constants.API_KEY);
        call.enqueue(new Callback<AllData>() {
            @Override
            public void onResponse(Call<AllData> call, Response<AllData> response) {

            }
                if (response.isSuccessful()) {
                    //staus.setValue(Status.SUCCESS);
                    //dismiss the progress in success
                    dialog.dismiss();
                    _allData.setValue(response.body());
            }

            @Override
            public void onFailure(Call<AllData> call, Throwable t) {
                //staus.setValue(Status.ERROR);
            }
        });

    }
</code>```

Body:
I have this flow in my app:

declare endpoints:

public interface EndPoints {
    @GET(Constants.POPULAR)
    Call<AllData> getAllData(
            @Query("api_key") String apiKey
    );
}

Retrofit service:

  private static EndPoints endPoints = retrofit.create(EndPoints.class);

    public static EndPoints getEndpoints() {
        return  endPoints ;
    }

And I call this inside my view model:

   private void getDataFromApi() {
    Call<AllData> call = RetrofitService.getEndPoints().getAllData(Constants.API_KEY);
    call.enqueue(new Callback<AllData>() {
        @Override
        public void onResponse(Call<AllData> call, Response<AllData> response) {

        }
            if (response.isSuccessful()) {
                _allData.setValue(response.body());
        }

        @Override
        public void onFailure(Call<AllData> call, Throwable t) {
        }
    });

}

Base Activity:

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
    }

Progress bar layout(I updated this instead of using frame layout every xml file, I created xml called progress bar layout and I want to inflate this every call):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>
</FrameLayout>

How can I set progress bar every api call?

Initally I checked in getDataFromApi if is loading or not, set the value into bool LiveData and observed this inside my activity.

The problem with this is it's an insane amount of code duplication.

Every api call I need to set loading state, every activity I need to observer the loading state and call View.Visible and View.Hide and every activity xml I need to create frame layout with progress bar.

I believe the answer is somewhere inside the base activity as it is the only place that can "control" all the activities in the app, but I can't think of a way of solving this problem

Body:
If you used status solely for purpose of showing ProgressBar then you can try changing your getDataFromApi() to take Context object as argument and then show a AlertDialog which contains a ProgressBar(modify it as you like depending on your need) and then dismiss() it in response.isSuccessful() being true.

private void getDataFromApi(Context context) {
           // status.setValue(Status.LOADING);
           // start showing progressbar instead of setting the status
           // or actually u can do both depending on the usage of the `status` variable
        MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
        ProgressBar progressBar = new ProgressBar(this);
        progressBar.setIndeterminate(true);
        builder.setView(progressBar);
        final AlertDialog dialog = builder.show();

        Call<AllData> call = RetrofitService.getEndPoints().getAllData(Constants.API_KEY);
        call.enqueue(new Callback<AllData>() {
            @Override
            public void onResponse(Call<AllData> call, Response<AllData> response) {

            }
                if (response.isSuccessful()) {
                    //staus.setValue(Status.SUCCESS);
                    //dismiss the progress in success
                    dialog.dismiss();
                    _allData.setValue(response.body());
            }

            @Override
            public void onFailure(Call<AllData> call, Throwable t) {
                //staus.setValue(Status.ERROR);
            }
        });

    }


问:
Google SignIn user authentication opening in Popup window, need to open in same Tab itself using OAuth 2.0
I am using OAuth 2.0 for google SingIn, it is opening a popup window for user authentication but i want to open in same tab itself, please help me.
Thanks in advance.</p>

答:
You can use ux_mode: redirect to change Google to Redirect mode which will open in the same tab instead of in a popup.

Ref: https://developers.google.com/identity/sign-in/web/reference#gapiauth2clientconfig

Then on your redirect landing page, use auth2.currentUser.get() to retrieve the signed in Google User object.

(I know this is an old question, but this was one of the first results in a web search; thought it might help others who end up here as well)

ContentLicense: CC BY-SA 3.0


问:
Cast to decima in spark scala
I am having the input data in text format like below. I need to convert this into Decimal in spark Scala. Please help me the cast(DecimalType) statement.

+0000025.42

I have tried .cast(DecimalType(11,2)) and it is displaying Null

答:
Might be having some text characters in that column because of that It is not able to convert data to decimal(11,2) type & It is adding null in that column.

Check data in that column.

```<code>scala> val df = Seq(("+0000025.42"),("sample")).toDF
df: org.apache.spark.sql.DataFrame = [value: string]

scala> df.show(false)
+-----------+
|value      |
+-----------+
|+0000025.42|
|sample     |
+-----------+

scala> df.select($"value".cast("decimal(11,2)").as("value")).show(false)
+-----+
|value|
+-----+
|25.42|
|null |
+-----+

</code>```

Title: Cast to decima in spark scala

Body:
Might be having some text characters in that column because of that It is not able to convert data to decimal(11,2) type & It is adding null in that column.

Check data in that column.

scala> val df = Seq(("+0000025.42"),("sample")).toDF
df: org.apache.spark.sql.DataFrame = [value: string]

scala> df.show(false)
+-----------+
|value      |
+-----------+
|+0000025.42|
|sample     |
+-----------+

scala> df.select($"value".cast("decimal(11,2)").as("value")).show(false)
+-----+
|value|
+-----+
|25.42|
|null |
+-----+


问:
When you discard the reference to a SoftReference, will it's clearing still be put on the ReferenceQueue?
I want to understand under which conditions the garbage collector notifies you of clearing a soft reference. The documentation makes it clear it happens when an OOM might occur, but what if you discard the reference completely, GC will come around and collect the SoftReference might notice no other strong/softly references exists and clear the internal referred value.

ReferenceQueue<Object> cleared = new ReferenceQueue<>();
Object X = new Object();
SoftReference<Object> Xs = new SoftReference<>(X, cleared);

Thread.sleep(10);
X = null;
Xs = null;

System.GC();
Thread.sleep(100);
Reference ref;
while ((ref = cleared.poll()) != null) {
   System.err.println(ref);
}
```

So where are the rules around this queue documentated? There must be more corner cases than what I'm asking, so maybe the question has to be broadened a bit.

答:
It seems to me you have more than one question. The first is when a reference will appear on the reference queue.

The documentation (on purpose?) leaves room for interpretation, taken from here:

Provides reference-object classes, which support a limited degree of interaction with the garbage collector. A program may use a reference object to maintain a reference to some other object in such a way that the latter object may still be reclaimed by the collector. A program may also arrange to be notified some time after the collector has determined that the reachability of a given object has changed.

So, it happens some time after. Under the current implementation it is an async process, so the documentation is not wrong.

The second question you have starts with a false premises:

... GC will come around and collect the SoftReference...

Not really. GC will not even know about the existence of this SoftReference if it is not reachable. GC finds alive objects and everything else is garbage, as weird as it might sound. As such GC will not even know that there was a SoftReference as it never visits it. When this happens, nothing is put on the ReferenceQueue. For that to happen that SoftReference needs to be traversed, but since that never happened...

Simply because a SoftReference is unreachable does not imply the same about the referent. It is perfectly valid for the referent to be strongly reachable, but for the SoftReference to be unreachable.

To your last point (that I imply you will care about): when SR is reachable, but referent is dead. When GC discovers such a thing, it's supposed to clear the referent (subsequent get will return null) and post that on the ReferenceQueue, right? Well, almost. This depends on the actual GC. For a contra-example, take Shenandoah GC that has a flag called ShenandoahRefProcFrequency (defaults to 5). It shows how often should Weak References be cleared, if it's not 5, when such a scenario happens : the referent is declared "alive". This referent is kept artificially alive until that limit is hit.

Body:
I want to understand under which conditions the garbage collector notifies you of clearing a soft reference. The documentation makes it clear it happens when an OOM might occur, but what if you discard the reference completely, GC will come around and collect the SoftReference might notice no other strong/softly references exists and clear the internal referred value.

ReferenceQueue<Object> cleared = new ReferenceQueue<>();
Object X = new Object();
SoftReference<Object> Xs = new SoftReference<>(X, cleared);

Thread.sleep(10);
X = null;
Xs = null;

System.GC();
Thread.sleep(100);
Reference ref;
while ((ref = cleared.poll()) != null) {
   System.err.println(ref);
}

So where are the rules around this queue documentated? There must be more corner cases than what I'm asking, so maybe the question has to be broadened a bit.


问:
How to automate next() call in every route function? (express.js)
Hi I am facing the problem that I need to log each incomming request and the associated responses in my database. My current solution looks like the following:

./routes/customer.js

```<code>router.get('/', async (req, res, next) => {
    req.allCustomers = await fetchAllCustomers();
    res.status(200).send(req.allCustomers);
    next();  // <- this is my personal problem
});
</code>```

./middleware/logging.js

```<code>module.exports = function (req, res, next) {
    db.query(
        `INSERT INTO logging SET ?`,
         {
            request: JSON.stringify([req.body, req.params]),
            response: JSON.stringify(req.response)
         }
    );
}
</code>```

routes declaration

```<code>module.exports = function(app) {
    app.use(express.json());
    app.use('/api/customers', customers); // <- ROUTE ./routes/customer.js
    app.use(logging); // <- MIDDLEWARE ./middleware/logging.js
}

</code>```

I already mentioned my problem in my first piece of code. It is really repetitive to call next() in every route manually and I would like to avoid this. I already tried to load the middleware before all routes, call next() in the middleware function and execute my db query afterwards but I do not have the response at this point because of the async functionality.

Is there any way to handle this situation or will I need keep calling next() at the end of each route function?

答:
when you use express.Router class like you already did and then use this code

app.use('/api/customers', customers);```
</div>
</div>
</p>

<p>you don't have to write 'next()' inside callback function in router.get .</p>

<p>there is an example
create a router file named birds.js in the app directory, with the following content:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var express = require('express')
var router = express.Router()

// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
  console.log('Time: ', Date.now())
  next()
})
// define the home page route
router.get('/', function (req, res) {
  res.send('Birds home page')
})
// define the about route
router.get('/about', function (req, res) {
  res.send('About birds')
})

module.exports = router</code>```

Then, load the router module in the app:

var birds = require('./birds')

// ...

app.use('/birds', birds)```

Body:
Hi I am facing the problem that I need to log each incomming request and the associated responses in my database. My current solution looks like the following:

./routes/customer.js

router.get('/', async (req, res, next) => {
    req.allCustomers = await fetchAllCustomers();
    res.status(200).send(req.allCustomers);
    next();  // <- this is my personal problem
});

./middleware/logging.js

module.exports = function (req, res, next) {
    db.query(
        `INSERT INTO logging SET ?`,
         {
            request: JSON.stringify([req.body, req.params]),
            response: JSON.stringify(req.response)
         }
    );
}

routes declaration

module.exports = function(app) {
    app.use(express.json());
    app.use('/api/customers', customers); // <- ROUTE ./routes/customer.js
    app.use(logging); // <- MIDDLEWARE ./middleware/logging.js
}

I already mentioned my problem in my first piece of code. It is really repetitive to call next() in every route manually and I would like to avoid this. I already tried to load the middleware before all routes, call next() in the middleware function and execute my db query afterwards but I do not have the response at this point because of the async functionality.

Is there any way to handle this situation or will I need keep calling next() at the end of each route function?

Body:
when you use express.Router class like you already did and then use this code

app.use('/api/customers', customers);

you don't have to write 'next()' inside callback function in router.get .

there is an example
create a router file named birds.js in the app directory, with the following content:

var express = require('express')
var router = express.Router()

// middleware that is specific to this router
router.use(function timeLog (req, res, next) {
  console.log('Time: ', Date.now())
  next()
})
// define the home page route
router.get('/', function (req, res) {
  res.send('Birds home page')
})
// define the about route
router.get('/about', function (req, res) {
  res.send('About birds')
})

module.exports = router

Then, load the router module in the app:

var birds = require('./birds')

// ...

app.use('/birds', birds)


问:
Basic Inheritance in Java
I'm currently learning and working on an exercise for class. I'm able to get a printout that resembles what I need, but the data isn't populating with test inputs. Name comes back null, Age: 0 and ID: 0.

Here's the scenario:

Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the printAll member method and a separate println statement to output courseStudents's data. Sample output from the given program:

Name: Smith, Age: 20, ID: 9999

// ===== Code from file PersonData.java =====
public class PersonData {
   private int ageYears;
   private String lastName;

   public void setName(String userName) {
      lastName  = userName;
   }

   public void setAge(int numYears) {
      ageYears = numYears;
   }

   // Other parts omitted

   public void printAll() {
      System.out.print("Name: " + lastName);
      System.out.print(", Age: "  + ageYears);
   }
}
// ===== end =====

// ===== Code from file StudentData.java =====
public class StudentData extends PersonData {
   private int idNum;

   public void setID(int studentId) {
      idNum = studentId;
   }

   public int getID() {
      return idNum;
   }
}
// ===== end =====

// ===== Code from file StudentDerivationFromPerson.java =====
public class StudentDerivationFromPerson {
   public static void main (String [] args) {
      StudentData courseStudent = new StudentData();

      courseStudent.printAll();
      System.out.println(", ID: " + courseStudent.getID());

   }
}
// ===== end =====
```
<p>I'm sure that I'm overlooking something simple, but I'm not sure what. My code is the just the last few lines:</p>
<pre class="lang-java prettyprint-override"><code>courseStudent.printAll();
System.out.println(", ID: " + courseStudent.getID());
</code>```

答:
I think you haven't tried to assign the args into the instance courseStudent that you just initiated. You can try this and see if this works:

```<code>      // Assumming your input is in this form : <name> <age> <student_id>
      // For example: Adam 19 4000
      StudentData courseStudent = new StudentData();

      // We get the args and convert them with the appropriate types
      String name = args[0];
      int age = String.parseInt(args[1]);
      int id = String.parseInt(args[2]);

      // We assgin the values into `courseStudent`
      courseStudent.setName(name);
      courseStudent.setAge(age);
      courseStudent.setID(id);

      courseStudent.printAll();
      System.out.println(", ID: " + courseStudent.getID());
</code>```

Title: Basic Inheritance in Java

Body:
I'm currently learning and working on an exercise for class. I'm able to get a printout that resembles what I need, but the data isn't populating with test inputs. Name comes back null, Age: 0 and ID: 0.

Here's the scenario:

Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the printAll member method and a separate println statement to output courseStudents's data. Sample output from the given program:

Name: Smith, Age: 20, ID: 9999

// ===== Code from file PersonData.java =====
public class PersonData {
   private int ageYears;
   private String lastName;

   public void setName(String userName) {
      lastName  = userName;
   }

   public void setAge(int numYears) {
      ageYears = numYears;
   }

   // Other parts omitted

   public void printAll() {
      System.out.print("Name: " + lastName);
      System.out.print(", Age: "  + ageYears);
   }
}
// ===== end =====

// ===== Code from file StudentData.java =====
public class StudentData extends PersonData {
   private int idNum;

   public void setID(int studentId) {
      idNum = studentId;
   }

   public int getID() {
      return idNum;
   }
}
// ===== end =====

// ===== Code from file StudentDerivationFromPerson.java =====
public class StudentDerivationFromPerson {
   public static void main (String [] args) {
      StudentData courseStudent = new StudentData();

      courseStudent.printAll();
      System.out.println(", ID: " + courseStudent.getID());

   }
}
// ===== end =====

I'm sure that I'm overlooking something simple, but I'm not sure what. My code is the just the last few lines:

courseStudent.printAll();
System.out.println(", ID: " + courseStudent.getID());

Body:
I think you haven't tried to assign the args into the instance courseStudent that you just initiated. You can try this and see if this works:

      // Assumming your input is in this form : <name> <age> <student_id>
      // For example: Adam 19 4000
      StudentData courseStudent = new StudentData();

      // We get the args and convert them with the appropriate types
      String name = args[0];
      int age = String.parseInt(args[1]);
      int id = String.parseInt(args[2]);

      // We assgin the values into `courseStudent`
      courseStudent.setName(name);
      courseStudent.setAge(age);
      courseStudent.setID(id);

      courseStudent.printAll();
      System.out.println(", ID: " + courseStudent.getID());


答: In the while loop, count is increasing by one for 9 times and becomes 9. maybeNew method's if part runs for 5 times and increases the count 5. After 5, it does not affect the count since it is returning 0. Every turn for the while loop, you are creating a new object and it has initial counter=0, then program increases it by 1. maybeNew method does not affect the counter because it creates another object and it is not written or saved to the objects on the array. All of the objects in your array has counter=1 for this reason.</p>

Title: Not obtaining the correct output for the following code


问:
Can a regular expression be used as a key in a dictionary?
I want to create a dictionary where the keys are regular expressions:

```<code>d = {'a.*': some_value1, 'b.*': some_value2}
</code>```

Then, when I look into the dictionary:

```<code>d['apple']
</code>```

I want apple 'apple' to be matched against the keys which are regular expressions. If there is a complete match with a key/regular-expression then the corresponding value should be returned.

For example 'apple' matches with the regular expression 'a.*' completely, and so, some_value1 should be returned.

Of course, all of this assumes that the regular expression keys do not conflict (i.e. two keys should not both match the same string exactly). Let's say I can manually take care of this requirement when building my keys.

Is this possible in Python? If so, it would be quite an elegant and powerful construct!

答:
You can use this. It works for me. You need to ensure your keys are unique.</p>

```<code>word_mapping = {
    r'\W*J\W*2\W*W\W*' : ' j2w ', r'\W*power\W*on\W*': ' poweron ',
    r'\W*Some From Dase [0-9]*\W*' : ''
}

def correct_word_mapping(x, dic):
    for word in dic.keys():
        #if word in x:
        x = re.sub(word, dic[word], x, flags=re.IGNORECASE)
return x

print(correct_word_mapping("power on J 2 w PowerONJ2 w", word_mapping))
</code>```

Body:
I want to create a dictionary where the keys are regular expressions:

d = {'a.*': some_value1, 'b.*': some_value2}

Then, when I look into the dictionary:

d['apple']

I want apple 'apple' to be matched against the keys which are regular expressions. If there is a complete match with a key/regular-expression then the corresponding value should be returned.

For example 'apple' matches with the regular expression 'a.*' completely, and so, some_value1 should be returned.

Of course, all of this assumes that the regular expression keys do not conflict (i.e. two keys should not both match the same string exactly). Let's say I can manually take care of this requirement when building my keys.

Is this possible in Python? If so, it would be quite an elegant and powerful construct!

Body:
You can use this. It works for me. You need to ensure your keys are unique.

word_mapping = {
    r'\W*J\W*2\W*W\W*' : ' j2w ', r'\W*power\W*on\W*': ' poweron ',
    r'\W*Some From Dase [0-9]*\W*' : ''
}

def correct_word_mapping(x, dic):
    for word in dic.keys():
        #if word in x:
        x = re.sub(word, dic[word], x, flags=re.IGNORECASE)
return x

print(correct_word_mapping("power on J 2 w PowerONJ2 w", word_mapping))


问:
discourse can't send email
i installed a discourse on AWS bitnami edu3d.co. I did the following things but still can't send the login verification email.

config the discourse by this instruction https://docs.bitnami.com/bch/apps/discourse/configuration/configure-smtp/

in AWS, request email sending limits

in AWS, verify my email identity,

in AWS, send test email (it is correct)

create my credential

checked spam boxes (no email)

Thank you!

答:
The problem is solved. I guess problem is that I set the username and password wrongly.

```<code>smtp_address = ''
smtp_port = 587
smtp_domain = 'edu3d.co'
smtp_user_name = ''
smtp_password = ''
smtp_enable_start_tls = true
smtp_authentication = login
</code>```

If you have problem in setting smtp for the discourse installed on AWS EC2 bitnami. You can do the following checks.

1) check whether your VM instance can connect the smtp server (test if smtp_address and smtp_port are correct)

I found 25 is not responding and 465 sometimes broke too, 587 works well.

2) check whether your username and password set correctly.
AWS provides this instruction https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html

How I find the problem

I really can't figure out why the smtp setting is 'correct' but i just can't receive the email. So I changed to gmail, the setting is a bit easier than AWS SES. After change, I received the email immediately but it says the login method is not secure so Google blocked it. This proves the smtp setting is working. And according to previous test, my VM instance can connect to the smtp server. So there should have something wrong in the smtp setting.

I go to AWS SES, intending to check the my credential. But I can only create a new one. So I did, then I found I misunderstood the username and password. After change, the email is working. Great!

The following instruction is very helpful!
https://docs.bitnami.com/bch/apps/discourse/configuration/configure-smtp/

Title: discourse can't send email

Body:
The problem is solved. I guess problem is that I set the username and password wrongly.

smtp_address = ''
smtp_port = 587
smtp_domain = 'edu3d.co'
smtp_user_name = ''
smtp_password = ''
smtp_enable_start_tls = true
smtp_authentication = login

If you have problem in setting smtp for the discourse installed on AWS EC2 bitnami. You can do the following checks.

1) check whether your VM instance can connect the smtp server (test if smtp_address and smtp_port are correct)

I found 25 is not responding and 465 sometimes broke too, 587 works well.

2) check whether your username and password set correctly.
AWS provides this instruction https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-client-command-line.html

How I find the problem

I really can't figure out why the smtp setting is 'correct' but i just can't receive the email. So I changed to gmail, the setting is a bit easier than AWS SES. After change, I received the email immediately but it says the login method is not secure so Google blocked it. This proves the smtp setting is working. And according to previous test, my VM instance can connect to the smtp server. So there should have something wrong in the smtp setting.

I go to AWS SES, intending to check the my credential. But I can only create a new one. So I did, then I found I misunderstood the username and password. After change, the email is working. Great!

The following instruction is very helpful!
https://docs.bitnami.com/bch/apps/discourse/configuration/configure-smtp/


问:
Does my app meet standards for resizing for different screen sizes and ratios/PPI? Playstore ready?
So, I've been working on a Flutter app for a while now and I think I want to publish my first app. All the mechanics work well but I am worried it won't resize properly or meet the Playstore's standards.

I've read all the Playstore docs and they say that your app should resize to every device... does the review process when you submit your app enable the team to check if it fits for different devices and check which ones it doesn't work on?

I am also worried about padding... what happens if the user installs my app on a phone 20 pixels wide and my padding horizontally is 25... it would totally break! Is this just unrealistic worrying?

I've really simplified my code for my UI of my app below and wondering if there is anything that is obviously messing with the resizing or would make it not work. I've tested it on all my families physical devices and it seems to work so far... but I really am unsure. Any help/insight is greatly appreciated!

(Sorry if my question is stupid)

Main Screen:

```<code>import 'package:flutter/material.dart';

class SOTest extends StatefulWidget {
  @override
  _SOTestState createState() => _SOTestState();
}

class _SOTestState extends State<SOTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      resizeToAvoidBottomPadding: false,
      backgroundColor: Colors.lightBlueAccent,
      body: Container(
        color: Colors.lightBlueAccent,
        child: Stack(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(left: 10, right: 10, bottom: 10, top: 10),
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.only(bottom: 10, top: 10),
                      child: Container(
                        height: MediaQuery.of(context).size.width * 1.15 -
                            MediaQuery.of(context).size.width,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                InkWell(
                                  child: Container(
                                    padding: EdgeInsets.only(top: 5, bottom: 5, right: 5, left: 5),
                                    height: MediaQuery.of(context).size.width * 1.15 -
                                        MediaQuery.of(context).size.width,
                                    width: MediaQuery.of(context).size.width / 5,
                                    decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(
                                        Radius.circular(15),
                                      ),
                                      boxShadow: [
                                        BoxShadow(
                                          color: Colors.black54,
                                          offset: Offset(2, 1),
                                          blurRadius: 10,
                                        ),
                                      ],
                                    ),
                                    child: Center(
                                      child: FittedBox(
                                        child: Column(
                                          mainAxisAlignment: MainAxisAlignment.center,
                                          children: <Widget>[
                                            Text(
                                              'Level',
                                              style: TextStyle(
                                                  fontFamily: 'Ub',
                                                  color: Colors.grey,
                                                  fontSize: 35),
                                            ),
                                            Text(
                                              '15',
                                              style: TextStyle(
                                                  fontFamily: 'Ub',
                                                  color: Colors.indigoAccent,
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 50),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                                Padding(
                                  padding: EdgeInsets.only(left: 10),
                                  child: InkWell(
                                    child: Container(
                                      height: MediaQuery.of(context).size.width * 1.15 -
                                          MediaQuery.of(context).size.width,
                                      width: MediaQuery.of(context).size.width / 8,
                                      decoration: BoxDecoration(
                                          color: Colors.white,
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(15),
                                          ),
                                          boxShadow: [
                                            BoxShadow(
                                              color: Colors.black54,
                                              offset: Offset(2, 1),
                                              blurRadius: 10,
                                            ),
                                          ]),
                                      child: Center(child: Icon(Icons.chevron_right, size: MediaQuery.of(context).size.width / 9, color: Colors.indigoAccent,),),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Expanded(
                              child: Container(
                                child: Center(
                                  child: FittedBox(
                                    child: Column(
                                      children: <Widget>[
                                        Padding(
                                          padding: EdgeInsets.only(right: 45),
                                          child: Text(
                                            'Pattern',
                                            textScaleFactor: 1,
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                                fontFamily: 'Pacifico',
                                                fontSize: MediaQuery.of(context).size.width / 10,
                                                color: Colors.white),
                                          ),
                                        ),
                                        Padding(
                                          padding: EdgeInsets.only(left: 45),
                                          child: Text(
                                            'Cracker',
                                            textScaleFactor: 1,
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                                fontFamily: 'Pacifico',
                                                fontSize: MediaQuery.of(context).size.width / 10,
                                                color: Colors.white),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            ),
                            Container(
                              padding: EdgeInsets.only(top: 5, bottom: 5, left: 5, right: 5),
                              height: MediaQuery.of(context).size.width * 1.15 -
                                  MediaQuery.of(context).size.width,
                              width: MediaQuery.of(context).size.width / 5,
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.all(
                                  Radius.circular(15),
                                ),
                                boxShadow: [
                                  BoxShadow(
                                    color: Colors.black54,
                                    offset: Offset(2, 1),
                                    blurRadius: 10,
                                  ),
                                ],
                              ),
                              child: Center(
                                child: FittedBox(
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: <Widget>[
                                      Text(
                                        'Attempts',
                                        style: TextStyle(
                                            fontFamily: 'Ub',
                                            color: Colors.grey,
                                            fontSize: 35),
                                      ),
                                      Text(
                                        '1',
                                        style: TextStyle(
                                            fontFamily: 'Ub',
                                            color: Colors.indigoAccent,
                                            fontWeight: FontWeight.bold,
                                            fontSize: 50),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                    Stack(
                      children: <Widget>[
                        Center(
                          child: Container(
                            height: MediaQuery.of(context).size.width,
                            width: MediaQuery.of(context).size.width,
                            decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.all(
                                  Radius.circular(10),
                                ),
                                boxShadow: [
                                  BoxShadow(
                                    color: Colors.black54,
                                    offset: Offset(2, 1),
                                    blurRadius: 10,
                                  ),
                                ]),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
</code>```

NumSquare refers to:

```<code>InkWell(
      child: Container(
        width: MediaQuery.of(context).size.width / 6,
        height: MediaQuery.of(context).size.width / 6,
        decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.all(
              Radius.circular(10),
            ),
            boxShadow: [
              BoxShadow(
                color: Colors.black54,
                offset: Offset(2, 1),
                blurRadius: 10,
              ),
            ]),
        child: Center(
          child: Text(
            '16',
            textScaleFactor: 1,
            style: TextStyle(
                color: Colors.white,
                fontFamily: 'Ub',
                fontSize: MediaQuery.of(context).size.width / 12),
          ),
        ),
      ),
    );
</code>```

答: As far as I know, and based on personal experience the review process for the play store simply checks if your apk is malware free. The design itself will not factor into whether the app is accepted for publishing or not. </p>

Body:
So, I've been working on a Flutter app for a while now and I think I want to publish my first app. All the mechanics work well but I am worried it won't resize properly or meet the Playstore's standards.

I've read all the Playstore docs and they say that your app should resize to every device... does the review process when you submit your app enable the team to check if it fits for different devices and check which ones it doesn't work on?

I am also worried about padding... what happens if the user installs my app on a phone 20 pixels wide and my padding horizontally is 25... it would totally break! Is this just unrealistic worrying?

I've really simplified my code for my UI of my app below and wondering if there is anything that is obviously messing with the resizing or would make it not work. I've tested it on all my families physical devices and it seems to work so far... but I really am unsure. Any help/insight is greatly appreciated!

(Sorry if my question is stupid)

Main Screen:

import 'package:flutter/material.dart';

class SOTest extends StatefulWidget {
  @override
  _SOTestState createState() => _SOTestState();
}

class _SOTestState extends State<SOTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      resizeToAvoidBottomPadding: false,
      backgroundColor: Colors.lightBlueAccent,
      body: Container(
        color: Colors.lightBlueAccent,
        child: Stack(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(left: 10, right: 10, bottom: 10, top: 10),
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Padding(
                      padding: EdgeInsets.only(bottom: 10, top: 10),
                      child: Container(
                        height: MediaQuery.of(context).size.width * 1.15 -
                            MediaQuery.of(context).size.width,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                InkWell(
                                  child: Container(
                                    padding: EdgeInsets.only(top: 5, bottom: 5, right: 5, left: 5),
                                    height: MediaQuery.of(context).size.width * 1.15 -
                                        MediaQuery.of(context).size.width,
                                    width: MediaQuery.of(context).size.width / 5,
                                    decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(
                                        Radius.circular(15),
                                      ),
                                      boxShadow: [
                                        BoxShadow(
                                          color: Colors.black54,
                                          offset: Offset(2, 1),
                                          blurRadius: 10,
                                        ),
                                      ],
                                    ),
                                    child: Center(
                                      child: FittedBox(
                                        child: Column(
                                          mainAxisAlignment: MainAxisAlignment.center,
                                          children: <Widget>[
                                            Text(
                                              'Level',
                                              style: TextStyle(
                                                  fontFamily: 'Ub',
                                                  color: Colors.grey,
                                                  fontSize: 35),
                                            ),
                                            Text(
                                              '15',
                                              style: TextStyle(
                                                  fontFamily: 'Ub',
                                                  color: Colors.indigoAccent,
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 50),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                                Padding(
                                  padding: EdgeInsets.only(left: 10),
                                  child: InkWell(
                                    child: Container(
                                      height: MediaQuery.of(context).size.width * 1.15 -
                                          MediaQuery.of(context).size.width,
                                      width: MediaQuery.of(context).size.width / 8,
                                      decoration: BoxDecoration(
                                          color: Colors.white,
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(15),
                                          ),
                                          boxShadow: [
                                            BoxShadow(
                                              color: Colors.black54,
                                              offset: Offset(2, 1),
                                              blurRadius: 10,
                                            ),
                                          ]),
                                      child: Center(child: Icon(Icons.chevron_right, size: MediaQuery.of(context).size.width / 9, color: Colors.indigoAccent,),),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                            Expanded(
                              child: Container(
                                child: Center(
                                  child: FittedBox(
                                    child: Column(
                                      children: <Widget>[
                                        Padding(
                                          padding: EdgeInsets.only(right: 45),
                                          child: Text(
                                            'Pattern',
                                            textScaleFactor: 1,
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                                fontFamily: 'Pacifico',
                                                fontSize: MediaQuery.of(context).size.width / 10,
                                                color: Colors.white),
                                          ),
                                        ),
                                        Padding(
                                          padding: EdgeInsets.only(left: 45),
                                          child: Text(
                                            'Cracker',
                                            textScaleFactor: 1,
                                            textAlign: TextAlign.left,
                                            style: TextStyle(
                                                fontFamily: 'Pacifico',
                                                fontSize: MediaQuery.of(context).size.width / 10,
                                                color: Colors.white),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            ),
                            Container(
                              padding: EdgeInsets.only(top: 5, bottom: 5, left: 5, right: 5),
                              height: MediaQuery.of(context).size.width * 1.15 -
                                  MediaQuery.of(context).size.width,
                              width: MediaQuery.of(context).size.width / 5,
                              decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.all(
                                  Radius.circular(15),
                                ),
                                boxShadow: [
                                  BoxShadow(
                                    color: Colors.black54,
                                    offset: Offset(2, 1),
                                    blurRadius: 10,
                                  ),
                                ],
                              ),
                              child: Center(
                                child: FittedBox(
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: <Widget>[
                                      Text(
                                        'Attempts',
                                        style: TextStyle(
                                            fontFamily: 'Ub',
                                            color: Colors.grey,
                                            fontSize: 35),
                                      ),
                                      Text(
                                        '1',
                                        style: TextStyle(
                                            fontFamily: 'Ub',
                                            color: Colors.indigoAccent,
                                            fontWeight: FontWeight.bold,
                                            fontSize: 50),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                    Stack(
                      children: <Widget>[
                        Center(
                          child: Container(
                            height: MediaQuery.of(context).size.width,
                            width: MediaQuery.of(context).size.width,
                            decoration: BoxDecoration(
                                color: Colors.white,
                                borderRadius: BorderRadius.all(
                                  Radius.circular(10),
                                ),
                                boxShadow: [
                                  BoxShadow(
                                    color: Colors.black54,
                                    offset: Offset(2, 1),
                                    blurRadius: 10,
                                  ),
                                ]),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                                Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                  children: <Widget>[
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                    NumSquare(),
                                  ],
                                ),
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

NumSquare refers to:

InkWell(
      child: Container(
        width: MediaQuery.of(context).size.width / 6,
        height: MediaQuery.of(context).size.width / 6,
        decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.all(
              Radius.circular(10),
            ),
            boxShadow: [
              BoxShadow(
                color: Colors.black54,
                offset: Offset(2, 1),
                blurRadius: 10,
              ),
            ]),
        child: Center(
          child: Text(
            '16',
            textScaleFactor: 1,
            style: TextStyle(
                color: Colors.white,
                fontFamily: 'Ub',
                fontSize: MediaQuery.of(context).size.width / 12),
          ),
        ),
      ),
    );